/* Fluff System — الداشبورد والكروت والعدّادات (مملوك لوكيل: dashboard)
   شكل "Flowkit": كروت مسطحة بحواف صغيرة + زجاج خفيف (glass) + دخول متدرّج ولمعة عند الـ hover.
   بيستخدم توكنز base.css (--fx-glass-*, --fx-ease, --fx-muted…) وألوان Filament (--primary-500…) — مفيش hex للبراند هنا.
   المكوّنات: <x-counter> (.fx-counter) • <x-fx.stat> (.fx-stat) • <x-fx.ring> • <x-fx.sparkline> • <x-fx.section-header>
   الويدجتس: KpiBoard (.fx-board) • OrdersChart (.fx-duo) • OpsInsights (.fx-insights) • TeamLeaderboard (.fx-lb) • LowStock (.fx-level)
   ملاحظات: الأنيميشن كلها fill-mode backwards (مفيش transform بيفضل على أب فيه مودال)،
   والـ backdrop-filter على الكروت الطرفية بس (مش على أي wrapper فيه dropdown/مودال).
   ============================================================ */

/* ---------- توكنز الكروت (بتقرا توكنز الزجاج من base.css ولو لسه مش موجودة فيه قيم احتياطي) ---------- */
:root {
    --fxd-radius: 10px;
    --fxd-radius-sm: 8px;
    --fxd-pad: 18px;
    --fxd-gap: 16px;
    --fxd-bg: var(--fx-glass-bg, rgb(255 255 255 / .74));
    --fxd-bg-solid: var(--fx-card, #fff);
    --fxd-border: var(--fx-glass-border, rgb(20 20 50 / .075));
    --fxd-backdrop: var(--fx-glass-blur, blur(16px) saturate(160%)); /* فلتر كامل (زي base.css) */
    --fxd-shadow: var(--fx-glass-shadow, 0 1px 2px rgb(20 20 50 / .04), 0 8px 24px -16px rgb(20 20 50 / .16));
    --fxd-shadow-hover: 0 2px 6px rgb(20 20 50 / .05), 0 20px 40px -20px rgb(20 20 50 / .28);
    --fxd-highlight: var(--fx-glass-highlight, inset 0 1px 0 rgb(255 255 255 / .85)); /* ظل inset كامل */
    --fxd-ink: var(--gray-950);
    --fxd-muted: var(--fx-muted, rgb(20 20 50 / .58));
    --fxd-divider: var(--fx-divider, rgb(20 20 50 / .06));
    --fxd-track: color-mix(in oklab, var(--gray-400) 20%, transparent);
    --fxd-head-bg: color-mix(in oklab, var(--primary-500) 9%, transparent);
    --fxd-head-fg: var(--primary-700);
    --fxd-shine: rgb(255 255 255 / .55);
    --fxd-tile-mix: 14%;
}
.dark {
    --fxd-bg: var(--fx-glass-bg, color-mix(in oklab, var(--gray-900) 66%, transparent));
    --fxd-bg-solid: var(--fx-card, var(--gray-900));
    --fxd-border: var(--fx-glass-border, rgb(255 255 255 / .08));
    --fxd-shadow: var(--fx-glass-shadow, 0 1px 2px rgb(0 0 0 / .3), 0 12px 28px -16px rgb(0 0 0 / .6));
    --fxd-shadow-hover: 0 2px 6px rgb(0 0 0 / .35), 0 24px 44px -20px rgb(0 0 0 / .75);
    --fxd-highlight: var(--fx-glass-highlight, inset 0 1px 0 rgb(255 255 255 / .06));
    --fxd-ink: #fff;
    --fxd-track: rgb(255 255 255 / .08);
    --fxd-head-bg: color-mix(in oklab, var(--primary-400) 12%, transparent);
    --fxd-head-fg: var(--primary-300);
    --fxd-shine: rgb(255 255 255 / .08);
    --fxd-tile-mix: 18%;
}

/* ألوان دلالية مشتركة (--tone) للبيلز والبارات والنقط */
.fx-tone--primary { --tone: var(--primary-600); }
.fx-tone--success { --tone: var(--success-600); }
.fx-tone--danger  { --tone: var(--danger-600); }
.fx-tone--warning { --tone: var(--warning-600); }
.fx-tone--info    { --tone: var(--info-600); }
.fx-tone--gray    { --tone: var(--gray-500); }
.dark .fx-tone--primary { --tone: var(--primary-400); }
.dark .fx-tone--success { --tone: var(--success-400); }
.dark .fx-tone--danger  { --tone: var(--danger-400); }
.dark .fx-tone--warning { --tone: var(--warning-400); }
.dark .fx-tone--info    { --tone: var(--info-400); }
.dark .fx-tone--gray    { --tone: var(--gray-400); }
.fx-muted { color: var(--fxd-muted); }
.fx-text { color: var(--tone); font-weight: 700; }

/* ---------- العدّاد ---------- */
.fx-counter {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    border-radius: 6px;
}
.fx-counter__num { direction: ltr; unicode-bidi: isolate; }
.fx-counter--up { animation: fx-flash-up 1.6s var(--fx-ease); }
.fx-counter--down { animation: fx-flash-down 1.6s var(--fx-ease); }

@keyframes fx-flash-up {
    0%, 15% { color: var(--success-600); background-color: color-mix(in oklab, var(--success-500) 18%, transparent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--success-500) 18%, transparent); }
    100% { background-color: transparent; box-shadow: 0 0 0 4px transparent; }
}
@keyframes fx-flash-down {
    0%, 15% { color: var(--danger-600); background-color: color-mix(in oklab, var(--danger-500) 16%, transparent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--danger-500) 16%, transparent); }
    100% { background-color: transparent; box-shadow: 0 0 0 4px transparent; }
}
.dark .fx-counter--up { animation-name: fx-flash-up-dark; }
.dark .fx-counter--down { animation-name: fx-flash-down-dark; }
@keyframes fx-flash-up-dark {
    0%, 15% { color: var(--success-400); background-color: color-mix(in oklab, var(--success-400) 20%, transparent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--success-400) 20%, transparent); }
    100% { background-color: transparent; box-shadow: 0 0 0 4px transparent; }
}
@keyframes fx-flash-down-dark {
    0%, 15% { color: var(--danger-400); background-color: color-mix(in oklab, var(--danger-400) 18%, transparent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--danger-400) 18%, transparent); }
    100% { background-color: transparent; box-shadow: 0 0 0 4px transparent; }
}

/* ---------- سطح الزجاج (للكروت الطرفية بس) ---------- */
.fx-stat,
.fx-card,
.fx-live,
.fx-lb-me,
.fx-lb-podium__card,
.fx-lb-table-wrap,
.fx-lb__empty {
    background: var(--fxd-bg);
    border: 1px solid var(--fxd-border);
    border-radius: var(--fxd-radius);
    box-shadow: var(--fxd-shadow), var(--fxd-highlight);
    -webkit-backdrop-filter: var(--fxd-backdrop);
    backdrop-filter: var(--fxd-backdrop);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .fx-stat, .fx-card, .fx-live, .fx-lb-me, .fx-lb-podium__card, .fx-lb-table-wrap, .fx-lb__empty { background: var(--fxd-bg-solid); }
}

@keyframes fx-rise {
    from { opacity: 0; translate: 0 14px; scale: .985; }
    to { opacity: 1; translate: 0 0; scale: 1; }
}
@keyframes fx-fade { from { opacity: 0; } }
@keyframes fx-ping {
    0% { transform: scale(1); opacity: .6; }
    70%, 100% { transform: scale(2.8); opacity: 0; }
}
@keyframes fx-grow { from { transform: scaleX(0); } }
@keyframes fx-pop { from { transform: scale(0); } }

/* ---------- اللوحة والسكاشن ---------- */
.fx-board { display: flex; flex-direction: column; gap: 30px; }
.fx-board__section { min-width: 0; container-type: inline-size; }

.fx-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-block-end: 14px;
    animation: fx-fade var(--fx-dur-slow) var(--fx-ease) backwards;
}
.fx-section-head__icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: var(--fxd-radius-sm);
    color: var(--primary-600);
    background: color-mix(in oklab, var(--primary-500) var(--fxd-tile-mix), transparent);
}
.dark .fx-section-head__icon { color: var(--primary-300); }
.fx-section-head__icon svg { width: 17px; height: 17px; }
.fx-section-head__text { min-width: 0; }
.fx-section-head__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--fxd-ink);
}
.fx-section-head__subtitle {
    margin: 1px 0 0;
    font-size: .75rem;
    line-height: 1.4;
    color: var(--fxd-muted);
}
.fx-section-head__end { margin-inline-start: auto; flex: none; }

/* مؤشر "لايف" — الأرقام بتتحدّث لوحدها */
.fx-live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    font-size: .75rem;
    font-weight: 600;
    color: var(--fxd-muted);
    border-radius: 999px;
}
.fx-live__dot {
    position: relative;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success-500);
}
.fx-live__dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: inherit;
    animation: fx-ping 2.4s var(--fx-ease) infinite;
}

/* ---------- الشبكة ---------- */
.fx-grid {
    display: grid;
    gap: var(--fxd-gap);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
    grid-auto-flow: row dense;
}
.fx-grid > .fx-stat { container-type: inline-size; }
.fx-grid > .fx-stat--featured { grid-column: span 2; }
/* عدد أعمدة ثابت لكل سكشن (بيتحسب في kpi-board.blade من عدد الكروت) عشان الصفوف تتملي من غير فراغات */
@container (min-width: 760px) {
    .fx-grid--cols { grid-template-columns: repeat(var(--fx-cols), minmax(0, 1fr)); }
}

/* ============================================================
   كارت الرقم (x-fx.stat)
   tile:   [أيقونة ........ ↗]   inline: [الرقم      أيقونة]
           العنوان                       [العنوان    أيقونة]
           الرقم                          شيب الاتجاه
           ↗ 12% عن ...
   ============================================================ */
.fx-stat {
    --fx-c-500: var(--primary-500);
    --fx-c-600: var(--primary-600);
    --fx-c-400: var(--primary-400);
    --fx-c-300: var(--primary-300);
    --fx-c: var(--fx-c-500);
    --fx-c-strong: var(--fx-c-600);
    --fx-ink: var(--fxd-ink);
    --fx-pad: var(--fxd-pad);

    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "media go"
        "label label"
        "value value"
        "trend trend"
        "hint hint"
        "spark spark";
    grid-template-rows: auto auto auto auto auto 1fr;
    align-content: start;
    min-width: 0;
    padding: var(--fx-pad) var(--fx-pad) calc(var(--fx-pad) - 2px);
    color: inherit;
    text-decoration: none;
    transition:
        translate var(--fx-dur) var(--fx-ease),
        box-shadow var(--fx-dur) var(--fx-ease),
        border-color var(--fx-dur) var(--fx-ease);
    animation: fx-rise var(--fx-dur-slow) var(--fx-ease) backwards;
    animation-delay: calc(min(var(--fx-i, 0), 18) * 50ms);
}
.dark .fx-stat {
    --fx-c-strong: var(--fx-c-400);
}
.fx-stat--success { --fx-c-500: var(--success-500); --fx-c-600: var(--success-600); --fx-c-400: var(--success-400); --fx-c-300: var(--success-300); }
.fx-stat--danger  { --fx-c-500: var(--danger-500);  --fx-c-600: var(--danger-600);  --fx-c-400: var(--danger-400);  --fx-c-300: var(--danger-300); }
.fx-stat--warning { --fx-c-500: var(--warning-500); --fx-c-600: var(--warning-600); --fx-c-400: var(--warning-400); --fx-c-300: var(--warning-300); }
.fx-stat--info    { --fx-c-500: var(--info-500);    --fx-c-600: var(--info-600);    --fx-c-400: var(--info-400);    --fx-c-300: var(--info-300); }
.fx-stat--gray    { --fx-c-500: var(--gray-400);    --fx-c-600: var(--gray-500);    --fx-c-400: var(--gray-400);    --fx-c-300: var(--gray-300); }

/* لون خفيف جدًا في ركن الكارت (زي انعكاس على الزجاج) */
.fx-stat::before {
    content: "";
    position: absolute;
    z-index: -2;
    grid-area: auto;
    inset-block-start: -130px;
    inset-inline-start: -90px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle closest-side, color-mix(in oklab, var(--fx-c) 10%, transparent), transparent);
    pointer-events: none;
    transition: scale var(--fx-dur-slow) var(--fx-ease), opacity var(--fx-dur) var(--fx-ease);
}
.dark .fx-stat::before { background: radial-gradient(circle closest-side, color-mix(in oklab, var(--fx-c) 16%, transparent), transparent); }

/* لمعة بتعدي على الكارت عند الـ hover */
.fx-stat::after {
    content: "";
    position: absolute;
    z-index: 2;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, var(--fxd-shine) 48%, transparent 66%);
    translate: -115% 0;
    pointer-events: none;
}

@media (hover: hover) {
    .fx-stat:hover {
        translate: 0 -3px;
        box-shadow: var(--fxd-shadow-hover), var(--fxd-highlight);
        border-color: color-mix(in oklab, var(--fx-c) 30%, var(--fxd-border));
    }
    .fx-stat:hover::before { scale: 1.25; }
    .fx-stat:hover::after { translate: 115% 0; transition: translate 900ms var(--fx-ease); }
}
.fx-stat--link { cursor: pointer; }
.fx-stat--link:focus-visible {
    outline: 2px solid var(--fx-c);
    outline-offset: 2px;
}
.fx-stat--link:active { translate: 0 -1px; }

/* الأيقونة: مربع بلون فاتح + توهج ناعم وراه */
.fx-stat__media { grid-area: media; justify-self: start; margin-block-end: 14px; }
.fx-stat__icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--fxd-radius-sm);
    color: var(--fx-c-strong);
    background: color-mix(in oklab, var(--fx-c) var(--fxd-tile-mix), color-mix(in oklab, var(--fxd-bg-solid) 70%, transparent));
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--fx-c) 14%, transparent), var(--fxd-highlight);
    transition: scale var(--fx-dur) var(--fx-ease-spring), rotate var(--fx-dur) var(--fx-ease-spring);
}
.fx-stat__icon::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -14px;
    border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in oklab, var(--fx-c) 34%, transparent), transparent 75%);
    opacity: .55;
    filter: blur(6px);
    pointer-events: none;
    transition: opacity var(--fx-dur) var(--fx-ease), scale var(--fx-dur-slow) var(--fx-ease);
}
.dark .fx-stat__icon::before { opacity: .7; }
.fx-stat__icon svg { width: 21px; height: 21px; }
@media (hover: hover) {
    .fx-stat:hover .fx-stat__icon { rotate: -6deg; scale: 1.06; }
    .fx-stat:hover .fx-stat__icon::before { opacity: 1; scale: 1.15; }
}

/* سهم صغير في الركن لو الكارت لينك */
.fx-stat__go {
    grid-area: go;
    align-self: start;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    color: var(--fxd-muted);
    opacity: .55;
    transition: opacity var(--fx-dur) var(--fx-ease), color var(--fx-dur) var(--fx-ease), background-color var(--fx-dur) var(--fx-ease), translate var(--fx-dur) var(--fx-ease);
}
.fx-stat__go svg { width: 15px; height: 15px; }
[dir="ltr"] .fx-stat__go svg { scale: -1 1; }
@media (hover: hover) {
    .fx-stat:hover .fx-stat__go {
        opacity: 1;
        color: var(--fx-c-strong);
        background: color-mix(in oklab, var(--fx-c) 12%, transparent);
        translate: -2px -2px;
    }
    [dir="ltr"] .fx-stat:hover .fx-stat__go { translate: 2px -2px; }
}

/* العنوان والرقم */
.fx-stat__label {
    grid-area: label;
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--fxd-muted);
    overflow-wrap: anywhere;
}
.fx-stat__value {
    grid-area: value;
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    margin-block: 2px 4px;
    font-size: clamp(1.35rem, 1.05rem + .8vw, 1.85rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -.015em;
    color: var(--fx-ink);
    white-space: nowrap;
}
.fx-grid > .fx-stat .fx-stat__value { font-size: clamp(1.25rem, 12cqi, 1.9rem); }
.fx-grid > .fx-stat--featured .fx-stat__value { font-size: clamp(1.5rem, 8cqi, 2.45rem); }
.fx-stat--danger .fx-stat__value { color: var(--fx-c-strong); }
.fx-stat__value .fx-counter__affix {
    font-size: .52em;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--fxd-muted);
}
.fx-stat__value .fx-counter__prefix { margin-inline-end: .2em; }

/* سطر الاتجاه: "↗ 12% عن الشهر اللي فات" */
.fx-stat__trendline {
    grid-area: trend;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 6px;
    min-width: 0;
    font-size: .78rem;
    line-height: 1.5;
}
.fx-stat__trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 700;
    white-space: nowrap;
}
.fx-stat__trend-icon { width: 16px; height: 16px; flex: none; }
.fx-stat__trend .fx-counter__affix { font-size: inherit; color: inherit; }
.fx-stat__trend--good { --fx-t: var(--success-600); color: var(--fx-t); }
.fx-stat__trend--bad { --fx-t: var(--danger-600); color: var(--fx-t); }
.dark .fx-stat__trend--good { --fx-t: var(--success-400); }
.dark .fx-stat__trend--bad { --fx-t: var(--danger-400); }
.fx-stat__trend-label { color: var(--fxd-muted); font-weight: 500; }

.fx-stat__hint {
    grid-area: hint;
    min-width: 0;
    margin-block-start: 2px;
    font-size: .75rem;
    line-height: 1.5;
    color: var(--fxd-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- variant: inline (الرقم على جنب والأيقونة على الجنب التاني + شيب للنسبة) ---------- */
.fx-stat--inline {
    grid-template-areas:
        "value media"
        "label media"
        "trend trend"
        "hint hint"
        "spark spark";
    grid-template-rows: auto auto auto auto 1fr;
    column-gap: 12px;
}
.fx-stat--inline .fx-stat__media { justify-self: end; align-self: center; margin: 0; }
.fx-stat--inline .fx-stat__value { margin-block: 0; }
.fx-stat--inline .fx-stat__trendline { margin-block-start: 10px; }
.fx-stat--inline .fx-stat__trend {
    padding: 1px 8px;
    border-radius: 6px;
    background: color-mix(in oklab, var(--fx-t) 13%, transparent);
}
.fx-stat--inline .fx-stat__go { position: absolute; inset-block-start: 6px; inset-inline-end: 6px; opacity: 0; }
@media (hover: hover) { .fx-stat--inline:hover .fx-stat__go { opacity: 1; } }

/* لمعة الكارت كله لما رقمه يتغير من الـ polling */
.fx-stat:has(.fx-stat__value .fx-counter--up) {
    animation: fx-rise var(--fx-dur-slow) var(--fx-ease) backwards, fx-card-up 1.8s var(--fx-ease);
    animation-delay: calc(min(var(--fx-i, 0), 18) * 50ms), 0s;
}
.fx-stat:has(.fx-stat__value .fx-counter--down) {
    animation: fx-rise var(--fx-dur-slow) var(--fx-ease) backwards, fx-card-down 1.8s var(--fx-ease);
    animation-delay: calc(min(var(--fx-i, 0), 18) * 50ms), 0s;
}
@keyframes fx-card-up {
    0%, 20% { border-color: color-mix(in oklab, var(--success-500) 55%, transparent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--success-500) 16%, transparent), var(--fxd-shadow); }
}
@keyframes fx-card-down {
    0%, 20% { border-color: color-mix(in oklab, var(--danger-500) 55%, transparent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger-500) 14%, transparent), var(--fxd-shadow); }
}

/* ---------- الحلقة (نسب) ---------- */
.fx-ring {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 46px;
    height: 46px;
    color: var(--fx-c-strong, var(--primary-600));
}
.fx-ring__svg { width: 100%; height: 100%; overflow: visible; }
.fx-ring__track {
    fill: color-mix(in oklab, currentColor 7%, transparent);
    stroke: color-mix(in oklab, currentColor 15%, transparent);
    stroke-width: 4;
}
.fx-ring__bar {
    fill: none;
    stroke: currentColor;
    stroke-width: 4;
    stroke-linecap: round;
    filter: drop-shadow(0 0 3px color-mix(in oklab, currentColor 35%, transparent));
    transition: stroke-dasharray 1s var(--fx-ease);
    animation: fx-ring-in 1.3s var(--fx-ease) backwards;
    animation-delay: calc(min(var(--fx-i, 0), 18) * 50ms + 150ms);
}
.fx-ring--empty .fx-ring__bar { stroke-linecap: butt; }
.fx-ring__target {
    stroke: var(--fx-ink, currentColor);
    stroke-width: 2;
    stroke-linecap: round;
    opacity: .45;
}
.fx-ring--met .fx-ring__target { opacity: .25; }
.fx-ring__icon {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}
.fx-ring__icon svg { width: 18px; height: 18px; }
@keyframes fx-ring-in { from { stroke-dasharray: 0 100; } }

/* ---------- الخط الصغير (آخر 7 أيام) ---------- */
.fx-spark {
    position: relative;
    height: 42px;
    color: var(--fx-c-strong, var(--primary-500));
}
.fx-stat__spark {
    grid-area: spark;
    align-self: end;
    margin-block: 8px calc((var(--fx-pad) - 2px) * -1);
    margin-inline: calc(var(--fx-pad) * -1);
}
/* الكارت العريض: الخط في النص التاني من الكارت (جنب الرقم) بدل ما يطوّله */
.fx-stat--featured .fx-stat__spark {
    grid-area: auto; /* عشان الـ containing block يبقى الكارت كله مش خانة الجريد */
    position: absolute;
    inset-block-end: 0;
    inset-inline-end: 0;
    width: 52%;
    height: 58%;
    margin: 0;
    z-index: -1;
}
.fx-stat--featured.fx-stat--has-spark :is(.fx-stat__trendline, .fx-stat__hint) { max-width: 50%; }
.fx-spark__svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    animation: fx-draw 1.4s var(--fx-ease) backwards;
    animation-delay: calc(min(var(--fx-i, 0), 18) * 50ms + 250ms);
}
.fx-spark__line { stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.fx-spark__dot {
    position: absolute;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 2px var(--fx-dot-ring, #fff);
    animation: fx-pop .5s var(--fx-ease-spring) backwards;
    animation-delay: calc(min(var(--fx-i, 0), 18) * 50ms + 1.3s);
}
.dark .fx-spark__dot { --fx-dot-ring: var(--gray-900); }
.fx-spark__dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    animation: fx-ping 2.6s var(--fx-ease) 2s infinite;
}
@keyframes fx-draw {
    from { clip-path: inset(-10% 100% -10% 0); }
    to { clip-path: inset(-10% 0 -10% 0); }
}

/* ---------- كارت "هيرو" (الرقم الأهم — متاح للسحب مثلاً) ---------- */
.fx-stat--hero {
    --fxd-muted: rgb(255 255 255 / .8);
    --fx-ink: #fff;
    --fx-c-strong: #fff;
    --fx-dot-ring: var(--fx-c-600);
    --fxd-shine: rgb(255 255 255 / .22);
    border-color: transparent;
    color: #fff;
    background:
        radial-gradient(120% 140% at 100% 0%, rgb(255 255 255 / .2), transparent 55%),
        linear-gradient(135deg, var(--fx-c-500), var(--fx-c-600) 55%, color-mix(in oklab, var(--fx-c-600) 78%, #000));
    box-shadow: 0 14px 32px -14px color-mix(in oklab, var(--fx-c-600) 75%, transparent), inset 0 1px 0 rgb(255 255 255 / .25);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}
.dark .fx-stat--hero { --fx-ink: #fff; --fx-c-strong: #fff; --fx-dot-ring: var(--fx-c-600); }
.fx-stat--hero::before { background: radial-gradient(closest-side, rgb(255 255 255 / .2), transparent); }
.fx-stat--hero .fx-stat__icon {
    color: #fff;
    background: rgb(255 255 255 / .18);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / .28);
}
.fx-stat--hero .fx-stat__icon::before { display: none; }
.fx-stat--hero .fx-stat__trend--good,
.fx-stat--hero .fx-stat__trend--bad { --fx-t: #fff; }
.fx-stat--hero .fx-stat__go { color: #fff; }
@media (hover: hover) {
    .fx-stat--hero:hover { border-color: transparent; box-shadow: 0 20px 44px -16px color-mix(in oklab, var(--fx-c-600) 85%, transparent), inset 0 1px 0 rgb(255 255 255 / .25); }
}

/* ============================================================
   كارت عام (fx-card) — رأس: عنوان على جنب وشيب صغير على الجنب التاني
   ============================================================ */
.fx-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0 0 var(--fxd-pad);
    animation: fx-rise var(--fx-dur-slow) var(--fx-ease) backwards;
    animation-delay: calc(min(var(--fx-i, 0), 18) * 70ms + 80ms);
}
.fx-card--flush { padding-block-end: 0; overflow: hidden; }
.fx-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: var(--fxd-pad) var(--fxd-pad) 14px;
}
.fx-card__titles { min-width: 0; }
.fx-card__title {
    margin: 0;
    font-size: .975rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--fxd-ink);
}
.fx-card__sub {
    margin: 2px 0 0;
    font-size: .75rem;
    line-height: 1.5;
    color: var(--fxd-muted);
}
/* شيب الفترة (شبه "Year ▾" في الريفرنس بس معلومة مش قايمة) */
.fx-card__chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--fxd-muted);
    border: 1px solid var(--fxd-border);
    border-radius: 7px;
    background: color-mix(in oklab, var(--fxd-bg-solid) 55%, transparent);
    white-space: nowrap;
}
.fx-card__chip svg { width: 14px; height: 14px; }

.fx-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 4px var(--fxd-pad) 0;
    padding: 28px 16px;
    text-align: center;
    font-size: .85rem;
    color: var(--fxd-muted);
    border: 1px dashed var(--fxd-border);
    border-radius: var(--fxd-radius-sm);
}
.fx-card--flush > .fx-empty { margin-block-end: var(--fxd-pad); }
.fx-empty svg { width: 20px; height: 20px; flex: none; opacity: .7; }

/* بيل رقم (زي "41,560" في الريفرنس) */
.fx-pill {
    --tone: var(--gray-500);
    flex: none;
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 6px;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.6;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--tone);
    background: color-mix(in oklab, var(--tone) 12%, transparent);
}

/* شريط تقدّم صغير (تيل) */
.fx-meter {
    position: relative;
    display: block;
    height: 6px;
    border-radius: 999px;
    background: var(--fxd-track);
    overflow: hidden;
}
.fx-meter > span {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--w, 0%);
    border-radius: inherit;
    background: linear-gradient(to left, var(--tone, var(--primary-500)), color-mix(in oklab, var(--tone, var(--primary-500)) 65%, #fff));
    transform-origin: right center;
    transition: width var(--fx-dur-slow) var(--fx-ease);
    animation: fx-grow 1s var(--fx-ease) backwards;
    animation-delay: calc(min(var(--fx-i, 0), 18) * 60ms + 300ms);
}
[dir="ltr"] .fx-meter > span { transform-origin: left center; background: linear-gradient(to right, var(--tone, var(--primary-500)), color-mix(in oklab, var(--tone, var(--primary-500)) 65%, #fff)); }
.dark .fx-meter > span { background: var(--tone, var(--primary-400)); }
.fx-meter--soft > span { --tone: color-mix(in oklab, var(--primary-500) 55%, var(--gray-400)); }

/* ============================================================
   الرسم + حالة الأوردرات (OrdersChart)
   ============================================================ */
.fx-duo-wrap { container-type: inline-size; }
.fx-duo { display: grid; gap: var(--fxd-gap); grid-template-columns: minmax(0, 1fr); }
@container (min-width: 980px) {
    .fx-duo { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
}
/* فيو الرسم الأصلي بيحط كلاسات عمود الجريد بتاع الصفحة على نفسه — جوه fx-duo بنلغيها */
.fx-duo > .fi-wi-chart { min-width: 0; grid-column: auto; }
.fx-duo > .fi-wi-chart > .fi-section { height: 100%; animation: fx-rise var(--fx-dur-slow) var(--fx-ease) backwards; animation-delay: 80ms; }

.fx-status__body {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    padding-inline: var(--fxd-pad);
    flex: 1;
}
@container (min-width: 980px) {
    .fx-status__body { grid-template-columns: minmax(0, 1fr); justify-items: center; }
    .fx-status__body .fx-legend { width: 100%; }
}
.fx-donut { position: relative; width: 150px; aspect-ratio: 1; }
.fx-donut__svg { display: block; width: 100%; height: 100%; overflow: visible; }
.fx-donut__track { fill: none; stroke: var(--fxd-track); stroke-width: 13; }
.fx-donut__seg {
    --tone: var(--gray-400);
    fill: none;
    stroke: var(--tone);
    stroke-width: 13;
    transition: stroke-width var(--fx-dur) var(--fx-ease), opacity var(--fx-dur) var(--fx-ease);
    animation: fx-donut-in 1.1s var(--fx-ease) backwards;
    animation-delay: calc(var(--fx-i, 0) * 90ms + 250ms);
}
.fx-donut__seg:hover { stroke-width: 16; }
@keyframes fx-donut-in { from { stroke-dasharray: 0 100; } }
.fx-donut__center {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
    line-height: 1.2;
}
.fx-donut__center b { font-size: 1.6rem; font-weight: 800; color: var(--fxd-ink); }
.fx-donut__center span { font-size: .75rem; color: var(--fxd-muted); }

/* ألوان حالات الأوردر (نفس ترتيب رحلة الأوردر) */
.fx-st--new { --tone: var(--info-400); }
.fx-st--on_hold { --tone: var(--warning-400); }
.fx-st--confirmed { --tone: var(--primary-500); }
.fx-st--shipped { --tone: var(--info-600); }
.fx-st--delivered { --tone: var(--success-500); }
.fx-st--partially_delivered { --tone: var(--success-300); }
.fx-st--returned { --tone: var(--danger-500); }
.fx-st--cancelled { --tone: var(--gray-400); }
.dark .fx-st--cancelled { --tone: var(--gray-500); }

.fx-legend { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.fx-legend__row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto 3.6em;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 6px;
    font-size: .8125rem;
    animation: fx-fade var(--fx-dur-slow) var(--fx-ease) backwards;
    animation-delay: calc(var(--fx-i, 0) * 60ms + 350ms);
    transition: background-color var(--fx-dur-fast) var(--fx-ease);
}
.fx-legend__row:hover { background: color-mix(in oklab, var(--tone) 8%, transparent); }
.fx-legend__dot { width: 9px; height: 9px; border-radius: 3px; background: var(--tone); }
.fx-legend__label { color: var(--fxd-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-legend__count { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--fxd-ink); }
.fx-legend__pct { font-size: .72rem; color: var(--fxd-muted); text-align: end; font-variant-numeric: tabular-nums; }

/* ============================================================
   كروت الشهر (OpsInsights): قوايم + جدول صغير
   ============================================================ */
.fx-insights-widget { container-type: inline-size; }
.fx-insights { display: grid; gap: var(--fxd-gap); grid-template-columns: minmax(0, 1fr); }
@container (min-width: 720px) {
    .fx-insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fx-insights > :last-child { grid-column: 1 / -1; }
}
@container (min-width: 1120px) {
    .fx-insights { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); }
    .fx-insights > :last-child { grid-column: auto; }
}

.fx-list { display: grid; gap: 4px; margin: 0; padding: 0 var(--fxd-pad); list-style: none; }
.fx-list__row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-block-end: 1px solid var(--fxd-divider);
    animation: fx-fade var(--fx-dur-slow) var(--fx-ease) backwards;
    animation-delay: calc(var(--fx-i, 0) * 60ms + 250ms);
}
.fx-list__row:last-child { border-block-end: 0; }
.fx-list__rank, .fx-list__avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--fxd-radius-sm);
    font-size: .8rem;
    font-weight: 800;
    color: var(--fxd-muted);
    background: color-mix(in oklab, var(--gray-400) 13%, transparent);
}
.fx-list__rank--top { color: var(--primary-700); background: color-mix(in oklab, var(--primary-500) 16%, transparent); }
.dark .fx-list__rank--top { color: var(--primary-300); }
.fx-list__avatar { border-radius: 50%; color: var(--primary-700); background: color-mix(in oklab, var(--primary-500) 12%, transparent); font-weight: 700; }
.dark .fx-list__avatar { color: var(--primary-300); }
.fx-list__main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.fx-list__line { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.fx-list__name { min-width: 0; font-size: .875rem; font-weight: 600; color: var(--fxd-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-list__sub { font-size: .72rem; color: var(--fxd-muted); line-height: 1.4; }

/* جدول بهيدر ملوّن خفيف (زي "Visitors By Channel") */
.fx-tbl-wrap { overflow-x: auto; margin: 0 var(--fxd-pad) var(--fxd-pad); border: 1px solid var(--fxd-divider); border-radius: var(--fxd-radius-sm); }
.fx-tbl { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.fx-tbl th {
    padding: 9px 12px;
    text-align: start;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--fxd-head-fg);
    background: var(--fxd-head-bg);
}
.fx-tbl td { padding: 10px 12px; border-top: 1px solid var(--fxd-divider); white-space: nowrap; vertical-align: middle; }
.fx-tbl tbody tr { animation: fx-fade var(--fx-dur-slow) var(--fx-ease) backwards; animation-delay: calc(var(--fx-i, 0) * 60ms + 250ms); transition: background-color var(--fx-dur-fast) var(--fx-ease); }
.fx-tbl tbody tr:hover { background: color-mix(in oklab, var(--primary-500) 5%, transparent); }
.fx-tbl__strong { font-weight: 700; color: var(--fxd-ink); }
.fx-tbl__num { font-variant-numeric: tabular-nums; font-weight: 600; }
.fx-rate { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.fx-rate .fx-meter { flex: 1; min-width: 56px; }
.fx-rate .fx-meter > span { background: var(--tone); }
.fx-rate b { min-width: 3.2em; font-size: .78rem; color: var(--tone); font-variant-numeric: tabular-nums; }

/* ---------- مستوى المخزون (جدول أصناف قربت تخلص) ---------- */
.fx-level {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
    padding: 8px 12px;
}
.fx-level__bar {
    position: relative;
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: var(--fxd-track);
    overflow: hidden;
}
.fx-level__fill {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    border-radius: inherit;
    background: var(--warning-500);
    animation: fx-grow .9s var(--fx-ease) backwards;
    transform-origin: right;
}
[dir="ltr"] .fx-level__fill { transform-origin: left; }
.fx-level--out .fx-level__fill { background: var(--danger-500); }
.fx-level__text {
    flex: none;
    font-size: .75rem;
    font-weight: 600;
    color: var(--fxd-muted);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   ترتيب الفريق (fx-lb) — كارت أداءك + أرقام الفريق + منصة أول 3 + جدول الترتيب
   ============================================================ */
.fx-lb { display: grid; gap: var(--fxd-gap); }
.fx-lb__periods { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--fx-segment-bg, var(--fxd-track)); border: 1px solid var(--fxd-border); }
.fx-lb__period { border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600; padding: 5px 14px; border-radius: 7px; color: var(--fxd-muted); cursor: pointer; transition: background-color var(--fx-dur-fast) var(--fx-ease), color var(--fx-dur-fast), box-shadow var(--fx-dur-fast); }
.fx-lb__period:hover { color: var(--fxd-ink); }
.fx-lb__period.is-active { background: var(--fx-segment-active, var(--fxd-bg-solid)); color: var(--primary-700); box-shadow: 0 1px 2px rgb(20 20 50 / .08), inset 0 0 0 1px var(--fxd-border); }
.dark .fx-lb__period.is-active { color: var(--primary-300); }
.fx-lb__period:focus-visible { outline: 2px solid var(--primary-500); outline-offset: 1px; }
.fx-lb__empty { display: grid; justify-items: center; gap: 6px; padding: 32px; color: var(--fxd-muted); }
.fx-lb__empty-icon { font-size: 28px; }
.fx-lb-muted { color: var(--fxd-muted); font-size: 12px; }

/* كارت أداءك */
.fx-lb-me {
    position: relative; overflow: hidden; isolation: isolate;
    display: grid; grid-template-columns: auto minmax(220px, 1.2fr) minmax(280px, 2fr); gap: 20px 28px; align-items: center;
    padding: 20px 24px;
    animation: fx-rise var(--fx-dur-slow) var(--fx-ease) backwards;
}
.fx-lb-me::before {
    content: ""; position: absolute; z-index: -1; inset-block-start: -80%; inset-inline-start: -10%; width: 60%; aspect-ratio: 1; border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in oklab, var(--primary-500) 16%, transparent), transparent); pointer-events: none;
}
.fx-lb-me__rank { display: grid; justify-items: center; gap: 2px; padding: 12px 18px; border-radius: var(--fxd-radius-sm); background: color-mix(in oklab, var(--primary-500) 11%, transparent); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--primary-500) 16%, transparent); min-width: 110px; }
.fx-lb-me__rank-label, .fx-lb-me__rank-of { font-size: 12px; color: var(--fxd-muted); }
.fx-lb-me__rank-num { font-size: 30px; font-weight: 800; line-height: 1.1; color: var(--primary-600); font-variant-numeric: tabular-nums; }
.dark .fx-lb-me__rank-num { color: var(--primary-300); }
.fx-lb-me__money { display: grid; gap: 4px; }
.fx-lb-me__label { font-size: 13px; color: var(--fxd-muted); }
.fx-lb-me__total { font-size: clamp(26px, 3vw, 34px); font-weight: 800; line-height: 1.15; color: var(--fxd-ink); }
.fx-lb-me__split { font-size: 13px; color: var(--fxd-muted); }
.fx-lb-me__split b { color: var(--fxd-ink); font-weight: 700; }
.fx-lb-me__gap { justify-self: start; margin-top: 4px; font-size: 12.5px; padding: 3px 10px; border-radius: 6px; background: color-mix(in oklab, var(--warning-500) 16%, transparent); color: var(--warning-700); }
.dark .fx-lb-me__gap { color: var(--warning-300); }
.fx-lb-me__meters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fx-lb-me__msg { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 12px; border-top: 1px dashed var(--fxd-divider); font-weight: 600; }

/* عدّاد نسبة مع علامة متوسط الفريق */
.fx-lb-meter { --c: var(--gray-400); display: grid; gap: 6px; }
.fx-lb-meter--great { --c: var(--success-500); }
.fx-lb-meter--ok { --c: var(--warning-500); }
.fx-lb-meter--low { --c: var(--danger-500); }
.fx-lb-meter__head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--fxd-muted); }
.fx-lb-meter__head b { font-size: 20px; color: var(--fxd-ink); font-variant-numeric: tabular-nums; }
.fx-lb-meter__bar { position: relative; height: 8px; border-radius: 999px; background: var(--fxd-track); overflow: visible; }
.fx-lb-meter__bar > span { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--w); border-radius: inherit; background: var(--c); box-shadow: 0 0 10px -2px color-mix(in oklab, var(--c) 60%, transparent); transform-origin: right center; animation: fx-grow 1s var(--fx-ease) 200ms backwards; }
[dir="ltr"] .fx-lb-meter__bar > span { transform-origin: left center; }
.fx-lb-meter__bar > i { position: absolute; top: -4px; bottom: -4px; inset-inline-start: var(--at); width: 2px; border-radius: 2px; background: var(--fxd-ink); opacity: .45; }
.fx-lb-meter__foot { font-size: 12px; color: var(--fxd-muted); }
.fx-lb-meter__foot .up { color: var(--success-600); font-weight: 600; }
.fx-lb-meter__foot .down { color: var(--danger-600); font-weight: 600; }
.dark .fx-lb-meter__foot .up { color: var(--success-400); }
.dark .fx-lb-meter__foot .down { color: var(--danger-400); }

/* أرقام الفريق (كروت x-fx.stat inline) */
.fx-lb-team { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--fxd-gap); }

/* المنصة */
.fx-lb-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--fxd-gap); align-items: end; }
.fx-lb-podium__card {
    --medal: var(--gray-400);
    position: relative; overflow: hidden; isolation: isolate; display: grid; justify-items: center; gap: 8px; text-align: center;
    padding: 18px 14px 16px;
    animation: fx-rise var(--fx-dur-slow) var(--fx-ease) backwards; animation-delay: calc(var(--fx-i, 0) * 90ms + 120ms);
    transition: translate var(--fx-dur) var(--fx-ease), box-shadow var(--fx-dur) var(--fx-ease);
}
.fx-lb-podium__card::before {
    content: ""; position: absolute; z-index: -1; inset: 0 0 auto; height: 70%;
    background: linear-gradient(180deg, color-mix(in oklab, var(--medal) 16%, transparent), transparent);
    pointer-events: none;
}
.fx-lb-podium__card::after {
    content: ""; position: absolute; inset-block-start: 0; inset-inline: 20%; height: 3px; border-radius: 0 0 3px 3px; background: var(--medal); opacity: .8;
}
@media (hover: hover) {
    .fx-lb-podium__card:hover { translate: 0 -3px; box-shadow: var(--fxd-shadow-hover), var(--fxd-highlight); }
}
.fx-lb-podium__card--1 { --medal: #f59e0b; padding-block: 26px 20px; }
.fx-lb-podium__card--2 { --medal: #94a3b8; }
.fx-lb-podium__card--3 { --medal: #c2410c; }
/* الأولى في النص على الديسكتوب */
@media (min-width: 768px) {
    .fx-lb-podium__card--1 { order: 2; }
    .fx-lb-podium__card--2 { order: 1; }
    .fx-lb-podium__card--3 { order: 3; }
}
.fx-lb-podium__card.is-me { border-color: var(--primary-500); box-shadow: var(--fxd-shadow), 0 0 0 1px var(--primary-500); }
.fx-lb-podium__medal { font-size: 30px; line-height: 1; filter: drop-shadow(0 4px 8px color-mix(in oklab, var(--medal) 45%, transparent)); }
.fx-lb-podium__card--1 .fx-lb-podium__medal { font-size: 38px; animation: fx-lb-bob 2.8s ease-in-out 1s infinite; }
.fx-lb-podium__total { font-size: 22px; font-weight: 800; color: var(--fxd-ink); }
.fx-lb-podium__card--1 .fx-lb-podium__total { font-size: 26px; }
.fx-lb-podium__meta { font-size: 12px; color: var(--fxd-muted); }

/* الجدول */
.fx-lb-table-wrap { overflow-x: auto; animation: fx-rise var(--fx-dur-slow) var(--fx-ease) 200ms backwards; }
.fx-lb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fx-lb-table th { text-align: start; font-size: 12px; font-weight: 700; color: var(--fxd-head-fg); padding: 11px 14px; white-space: nowrap; background: var(--fxd-head-bg); }
.fx-lb-table td { padding: 10px 14px; border-top: 1px solid var(--fxd-divider); white-space: nowrap; vertical-align: middle; }
.fx-lb-table tbody tr { transition: background-color var(--fx-dur-fast) var(--fx-ease); }
.fx-lb-table tbody tr:hover { background: color-mix(in oklab, var(--primary-500) 5%, transparent); }
.fx-lb-table tr.is-me { background: color-mix(in oklab, var(--primary-500) 9%, transparent); }
.fx-lb-table tr.is-me td:first-child { box-shadow: inset -3px 0 0 var(--primary-500); }
[dir="ltr"] .fx-lb-table tr.is-me td:first-child { box-shadow: inset 3px 0 0 var(--primary-500); }
.fx-lb-table__rank { font-weight: 800; font-size: 16px; text-align: center; width: 48px; }
.fx-lb-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.fx-lb-num--upsell { color: var(--success-700); }
.dark .fx-lb-num--upsell { color: var(--success-400); }
.fx-lb-num--total { font-weight: 800; font-size: 15px; color: var(--fxd-ink); }
.fx-lb-mini { display: inline-flex; align-items: center; gap: 8px; }
.fx-lb-mini__bar { position: relative; width: 72px; height: 6px; border-radius: 999px; background: var(--fxd-track); overflow: hidden; }
.fx-lb-mini__bar > span { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--w); border-radius: inherit; background: var(--c); transform-origin: right center; animation: fx-grow 900ms var(--fx-ease) 300ms backwards; }
[dir="ltr"] .fx-lb-mini__bar > span { transform-origin: left center; }
.fx-lb-badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.fx-lb-badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 6px; background: color-mix(in oklab, var(--primary-500) 10%, transparent); color: var(--fxd-ink); white-space: nowrap; }

@keyframes fx-lb-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }

@media (max-width: 1023px) {
    .fx-lb-me { grid-template-columns: auto 1fr; }
    .fx-lb-me__meters { grid-column: 1 / -1; }
    .fx-lb-team { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    .fx-lb .fx-section-head { flex-wrap: wrap; row-gap: 10px; }
    .fx-lb .fx-section-head__end { width: 100%; }
    .fx-lb__periods { display: flex; width: 100%; }
    .fx-lb__period { flex: 1; }
    .fx-lb-me { grid-template-columns: 1fr; padding: 16px; }
    .fx-lb-me__rank { justify-self: start; grid-auto-flow: column; align-items: baseline; gap: 8px; }
    .fx-lb-me__meters { grid-template-columns: 1fr; }
    .fx-lb-podium { grid-template-columns: 1fr; }
    /* الجدول يتحول لكروت */
    .fx-lb-table thead { display: none; }
    .fx-lb-table, .fx-lb-table tbody, .fx-lb-table tr, .fx-lb-table td { display: block; }
    .fx-lb-table tr { padding: 10px 14px; border-top: 1px solid var(--fxd-divider); }
    .fx-lb-table tr:first-child { border-top: 0; }
    .fx-lb-table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; white-space: normal; }
    .fx-lb-table td > .fx-lb-cell { text-align: end; }
    .fx-lb-table td::before { content: attr(data-label); color: var(--fxd-muted); font-size: 12px; }
    .fx-lb-table__rank { width: auto; text-align: start; }
    .fx-lb-table tr.is-me td:first-child { box-shadow: none; }
}

/* ---------- موبايل ---------- */
@media (max-width: 639px) {
    :root { --fxd-pad: 14px; --fxd-gap: 10px; }
    .fx-board { gap: 24px; }
    .fx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fx-stat { --fx-pad: 13px; }
    .fx-stat__media { margin-block-end: 10px; }
    .fx-stat__label { font-size: .75rem; }
    .fx-stat__icon { width: 36px; height: 36px; border-radius: 7px; }
    .fx-stat__icon svg { width: 18px; height: 18px; }
    .fx-stat__go { width: 22px; height: 22px; }
    .fx-ring { width: 38px; height: 38px; }
    .fx-ring__icon svg { width: 15px; height: 15px; }
    .fx-stat__trendline { font-size: .72rem; }
    .fx-stat__hint { font-size: .6875rem; }
    .fx-stat__spark { height: 34px; }
    .fx-grid > .fx-stat--featured .fx-stat__value { font-size: clamp(1.4rem, 9cqi, 2.2rem); }
    .fx-live { padding: 3px 9px; font-size: .6875rem; }
    .fx-section-head__icon { width: 30px; height: 30px; }
    .fx-status__body { grid-template-columns: minmax(0, 1fr); justify-items: center; }
    .fx-status__body .fx-legend { width: 100%; }
    .fx-card__head { flex-wrap: wrap; }
    .fx-tbl th, .fx-tbl td { padding-inline: 9px; }
    .fx-rate { min-width: 96px; gap: 6px; }
    .fx-rate .fx-meter { min-width: 40px; }
}

/* ---------- طباعة: الرقم النهائي على طول ---------- */
@media print {
    .fx-counter__live { visibility: hidden; }
    .fx-counter__ghost { opacity: 1 !important; }
    .fx-stat, .fx-card { animation: none !important; box-shadow: none; break-inside: avoid; backdrop-filter: none; }
}

/* ---------- تقليل الحركة ---------- */
@media (prefers-reduced-motion: reduce) {
    .fx-stat, .fx-stat::before, .fx-stat::after, .fx-stat__icon, .fx-stat__icon::before, .fx-stat__go,
    .fx-ring__bar, .fx-spark__svg, .fx-spark__dot, .fx-level__fill, .fx-section-head,
    .fx-card, .fx-meter > span, .fx-donut__seg, .fx-legend__row, .fx-list__row, .fx-tbl tbody tr,
    .fx-duo > .fi-wi-chart > .fi-section,
    .fx-lb-me, .fx-lb-podium__card, .fx-lb-table-wrap, .fx-lb-meter__bar > span, .fx-lb-mini__bar > span, .fx-lb-podium__medal,
    .fx-counter--up, .fx-counter--down { animation: none !important; transition: none !important; }
    .fx-stat::after { display: none; }
    .fx-spark__dot::after, .fx-live__dot::after { display: none; }
    .fx-stat:hover, .fx-lb-podium__card:hover { translate: none; }
}
