.app-shell {
    min-height: 100vh;
    padding: 0;
}

.app-shell--guest {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-4);
}

.app-shell__frame {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--shell-sidebar-width);
    /* هدر حذف شده — فقط محتوا و سایدبار. فریم تمام‌عرض و بدونِ padding/gap است تا سایدبار
       کاملاً به لبهٔ صفحه بچسبد و ارتفاعِ کاملِ viewport را بگیرد؛ padding/سقفِ عرض به خودِ محتوا منتقل شد. */
    grid-template-areas:
        "content sidebar";
    gap: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    align-items: start;
    direction: ltr;
}

.shell-header,
.shell-sidebar,
.card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-panel);
    box-shadow: var(--shadow-soft);
}

.shell-header {
    grid-area: header;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 34rem) auto;
    align-items: center;
    gap: var(--space-3);
    padding: 0.95rem 1.15rem;
    position: sticky;
    top: var(--shell-sticky-offset);
    z-index: 80;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(18px);
    direction: rtl;
}

.shell-header__brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.shell-header__brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.9rem;
    background: linear-gradient(135deg, rgba(45, 108, 223, 0.16), rgba(31, 79, 152, 0.22));
    color: var(--color-accent-strong);
    font-weight: 800;
}

.shell-header__brand-copy {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
}

.shell-header__brand-copy strong {
    color: var(--color-ink);
    font-size: 1rem;
}

.shell-header__brand-copy span {
    color: var(--color-ink-soft);
    font-size: 0.86rem;
}

.shell-header__search {
    width: 100%;
}

.shell-header__search input {
    width: 100%;
    padding: 0.86rem 1rem;
    border: 1px solid rgba(91, 103, 120, 0.14);
    border-radius: 999px;
    background: rgba(247, 249, 252, 0.92);
}

.shell-header__meta {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
}

.shell-header__meta .button {
    padding: 0.62rem 0.9rem;
    background: rgba(255, 255, 255, 0.76);
}

.shell-header__profile {
    display: inline-flex;
}

.shell-header__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.65rem;
    height: 2.65rem;
    border-radius: 999px;
    border: 1px solid rgba(45, 108, 223, 0.12);
    background: linear-gradient(135deg, rgba(45, 108, 223, 0.14), rgba(31, 79, 152, 0.2));
    color: var(--color-accent-strong);
    font-weight: 800;
    overflow: hidden;
}

.shell-header__avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shell-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    direction: ltr;
    min-height: 0;
    margin: 0 0 0.55rem;
    position: sticky;
    top: calc(var(--shell-sticky-offset) + var(--shell-header-height) - 0.65rem);
    z-index: 90;
    /* نوارِ ابزار شفاف و تمام‌عرض است ولی فقط یک‌دو آیکن دارد؛ بدونِ این، کلِ باندِ ۳۹پیکسلیِ
       شفاف کلیک‌ها را می‌بلعد و دکمه‌های محتوای زیرش کلیک‌ناپذیر می‌شوند. کلیک از باندِ خالی
       رد شود؛ فقط خودِ آیکن‌ها (shell-toolbar__action) کلیک بگیرند. */
    pointer-events: none;
}

.shell-toolbar__action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid rgba(91, 103, 120, 0.16);
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.86);
    color: var(--color-accent-strong);
    box-shadow: var(--shadow-soft);
}

.shell-toolbar__action:disabled,
.shell-toolbar__action.is-disabled {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.shell-toolbar__action svg {
    width: 1.05rem;
    height: 1.05rem;
}

.shell-toolbar__action::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.45rem);
    left: 50%;
    transform: translateX(-50%) translateY(0.2rem);
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    background: rgba(22, 32, 45, 0.9);
    color: #fff;
    font-size: 0.76rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 95;
    transition: opacity 140ms ease, transform 140ms ease;
}

.shell-toolbar__action:hover::after,
.shell-toolbar__action:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.shell-sidebar {
    grid-area: sidebar;
    align-self: start;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.55rem;
    /* سایدبارِ ثابت و تمام‌ارتفاع: به بالای صفحه می‌چسبد و کلِ ارتفاعِ viewport را می‌گیرد.
       خودِ پوسته اسکرول نمی‌شود (برند بالا ثابت، خروج پایین ثابت، ناوبریِ میانی منعطف). */
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    overscroll-behavior: contain;
    /* پنلِ تمام‌ارتفاعِ چسبیده به لبه: بدونِ گردیِ گوشه؛ فقط لبهٔ داخلیِ روبه‌محتوا قاب دارد. */
    border: 0;
    border-left: 1px solid var(--color-border);
    border-radius: 0;
    box-shadow: none;
    background:
        linear-gradient(180deg, rgba(45, 108, 223, 0.08), rgba(45, 108, 223, 0.02)),
        var(--color-panel-strong);
    direction: rtl;
}

.shell-sidebar__brand {
    flex: 0 0 auto;
    padding-bottom: 0.4rem;
    margin-bottom: 0.1rem;
    border-bottom: 1px solid var(--color-border);
}

.shell-sidebar__brand h2 {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.3;
}

/* 8.84 — بخشِ کاربرِ واردشده (جایگزینِ عنوانِ برند) — فشرده، هم‌ارتفاعِ قبلی */
.shell-sidebar__brand.shell-sidebar__user { display: flex; align-items: center; gap: 0.25rem; position: relative; }
.shell-sidebar__user-trigger {
    flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 0.5rem;
    background: transparent; border: 0; cursor: pointer; padding: 0.15rem 0.2rem; border-radius: 0.5rem;
    color: inherit; font: inherit; text-align: start;
}
.shell-sidebar__user-trigger:hover { background: rgba(45, 108, 223, 0.08); }
.shell-sidebar__user-trigger:focus-visible { outline: 2px solid rgba(45, 108, 223, 0.4); outline-offset: 2px; }
.shell-sidebar__avatar {
    position: relative; flex: 0 0 auto; width: 1.85rem; height: 1.85rem; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
    background: var(--color-accent, #2d6cdf); color: #fff; font-size: 0.78rem; font-weight: 700;
}
.shell-sidebar__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shell-sidebar__presence {
    position: absolute; bottom: 0; inset-inline-end: 0; width: 0.46rem; height: 0.46rem; border-radius: 50%;
    background: #22c55e; border: 1.5px solid var(--color-surface, #fff); box-sizing: content-box;
}
.shell-sidebar__user-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.shell-sidebar__user-name { font-size: 0.83rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-sidebar__user-role { font-size: 0.68rem; color: var(--color-ink-soft, #8a93a3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-sidebar__user-caret { width: 1rem; height: 1rem; flex: 0 0 auto; color: var(--color-ink-soft, #8a93a3); transition: transform 0.15s; }
.shell-sidebar__user-trigger[aria-expanded="true"] .shell-sidebar__user-caret { transform: rotate(180deg); }

/* جمع‌شده: فقط آواتار */
.shell-sidebar.is-collapsed .shell-sidebar__user-meta,
.shell-sidebar.is-collapsed .shell-sidebar__user-caret { display: none; }
.shell-sidebar.is-collapsed .shell-sidebar__user-trigger { justify-content: center; padding-inline: 0; }

/* منوی حساب (popover) */
.shell-account {
    position: absolute; z-index: 1300; top: 2.8rem; inset-inline-start: 0.4rem; inset-inline-end: 0.4rem;
    background: var(--color-surface, #fff); border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 0.7rem; box-shadow: 0 14px 40px rgba(15, 23, 42, 0.18); padding: 0.55rem; font-size: 0.82rem;
}
.shell-account[hidden] { display: none; }
.shell-account__head { display: flex; flex-direction: column; gap: 0.12rem; padding: 0.15rem 0.3rem 0.5rem; border-bottom: 1px solid var(--color-border, #eef2f7); margin-bottom: 0.35rem; }
.shell-account__name { font-size: 0.88rem; }
.shell-account__email { font-size: 0.71rem; color: var(--color-ink-soft, #8a93a3); }
.shell-account__role { font-size: 0.71rem; color: #3730a3; }
.shell-account__last { font-size: 0.69rem; color: var(--color-ink-soft, #8a93a3); }
.shell-account__note { font-size: 0.69rem; color: #15803d; margin-top: 0.2rem; }
.shell-account__nav { display: flex; flex-direction: column; }
.shell-account__nav a { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.35rem; border-radius: 0.45rem; color: inherit; text-decoration: none; }
.shell-account__nav a:hover { background: rgba(45, 108, 223, 0.08); }
.shell-account__nav svg { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; color: var(--color-ink-soft, #8a93a3); }
.shell-account__logout { margin-top: 0.35rem; border-top: 1px solid var(--color-border, #eef2f7); padding-top: 0.4rem; }
.shell-account__logout button { width: 100%; display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.5rem; border: 0; border-radius: 0.5rem; cursor: pointer; background: rgba(214, 69, 69, 0.1); color: #a3271f; font: inherit; font-weight: 700; }
.shell-account__logout button:hover { background: rgba(214, 69, 69, 0.18); }
.shell-account__logout svg { width: 1.05rem; height: 1.05rem; }

/* جمع‌شده: popover به‌صورتِ flyout با عرضِ ثابت */
.shell-sidebar.is-collapsed .shell-account { inset-inline: auto; inset-inline-start: 0.5rem; width: 14rem; max-width: calc(100vw - 1rem); }

.shell-nav {
    display: grid;
    gap: 0.2rem;
    margin-top: 0.4rem;
    /* فونتِ کوچک‌ترِ خوانا (~۱۲.۸px روی ریشهٔ ۱۶px)؛ از طریقِ قواعدِ inherit به همهٔ آیتم‌ها/زیرمنوها می‌رسد. */
    font-size: 0.8rem;
    line-height: 1.28;
    /* ناحیهٔ منعطفِ میانی: برند بالا و خروج پایین ثابت می‌مانند. در حالتِ معمول (گروه‌های جمع)
       همه‌چیز بدونِ اسکرول جا می‌شود؛ فقط اگر گروهی خیلی بزرگ باز شود این ناحیه اسکرولِ نامحسوس می‌گیرد
       (به‌جای بریده‌شدن/گم‌شدنِ آیتم‌ها). */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    align-content: start;
}

/* فونتِ فشردهٔ خوانا روی خودِ آیتم‌ها: قواعدِ `font: inherit`/`font-size: inherit` روی
   subitem/summary--nested اجازه نمی‌دهند font-size از .shell-nav ارث‌بری شود؛ پس صریح و با
   ویژگیِ (0,2,0) ست می‌شود تا روی همهٔ سطرها (لینک/گروه/زیرمنو) اعمال شود (~۱۲px روی ریشهٔ ۱۴px). */
.shell-sidebar .shell-nav__item,
.shell-sidebar .shell-nav__summary,
.shell-sidebar .shell-nav__subitem {
    font-size: 0.86rem;
}

.shell-nav__item,
.shell-nav__subitem {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 0.95rem;
    color: var(--color-ink);
}

.shell-nav__item {
    padding: 0.34rem 0.6rem;
    background: rgba(22, 32, 45, 0.04);
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.shell-nav__item:hover,
.shell-nav__subitem:hover {
    background: rgba(45, 108, 223, 0.08);
}

.shell-nav__item.is-active {
    background: rgba(45, 108, 223, 0.12);
    color: var(--color-accent-strong);
}

.shell-nav__group {
    border: 1px solid rgba(91, 103, 120, 0.12);
    border-radius: 1rem;
    background: rgba(22, 32, 45, 0.025);
}

.shell-nav__group--nested {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.shell-nav__group.is-active,
.shell-nav__group[open] {
    background: rgba(45, 108, 223, 0.07);
}

.shell-nav__group--nested.is-active,
.shell-nav__group--nested[open] {
    background: transparent;
}

.shell-nav__summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.34rem 0.6rem;
    cursor: pointer;
    color: var(--color-ink);
    font-weight: 700;
    list-style: none;
}

.shell-nav__summary--nested {
    padding: 0.34rem 0.6rem;
    font: inherit;
    font-weight: 700;
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.62);
}

.shell-nav__summary--nested:hover {
    background: rgba(45, 108, 223, 0.08);
}

.shell-nav__summary::-webkit-details-marker {
    display: none;
}

.shell-nav__summary::after {
    content: "▾";
    margin-inline-start: auto;
    font-size: 0.85rem;
    transition: transform 160ms ease;
}

.shell-nav__group[open] > .shell-nav__summary::after {
    transform: rotate(180deg);
}

.shell-nav__subnav {
    display: grid;
    gap: 0.15rem;
    padding-block: 0.1rem 0.2rem;
    padding-inline-start: 0;
    padding-inline-end: 0.4rem;
}

.shell-nav__subnav--nested {
    gap: 0.15rem;
    padding: 0.2rem 0 0;
}

.shell-nav__subitem {
    padding: 0.34rem 0.6rem;
    font: inherit;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.62);
}

.shell-nav__subitem--level-1 {
    width: calc(100% - 0.8rem);
    margin-inline-start: 0;
    margin-inline-end: 0.8rem;
}

.shell-nav__subitem--level-2 {
    width: calc(100% - 1.6rem);
    margin-inline-start: 0;
    margin-inline-end: 1.6rem;
}

.shell-nav__subitem--level-1,
.shell-nav__subitem--level-2,
.shell-nav__summary--nested {
    min-height: 1.9rem;
    line-height: 1.3;
    box-sizing: border-box;
}

.shell-nav__summary--level-1 {
    width: calc(100% - 0.8rem);
    margin-inline-start: 0;
    margin-inline-end: 0.8rem;
}

.shell-nav__summary--level-2 {
    width: calc(100% - 1.6rem);
    margin-inline-start: 0;
    margin-inline-end: 1.6rem;
}

.shell-nav__subitem--level-1,
.shell-nav__subitem--level-2,
.shell-nav__summary--level-1,
.shell-nav__summary--level-2 {
    padding-block: 0.34rem;
    padding-inline: 0.6rem;
    font-size: inherit;
}

.shell-nav__bullet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.85rem;
    color: var(--color-accent-strong);
    flex-shrink: 0;
}

.shell-nav__subitem.is-active {
    background: rgba(45, 108, 223, 0.12);
    color: var(--color-accent-strong);
}

/* نشانگرِ واضحِ آیتمِ فعالِ صفحهٔ جاری: نوارِ لبهٔ شروع (RTL: سمتِ راست) + وزنِ پررنگ‌تر.
   شاملِ هم لینک‌های ساده (a) و هم summaryِ گروهی که خودش صفحهٔ جاری است (is-current). */
.shell-nav__item.is-active,
.shell-nav__subitem.is-active,
.shell-nav__summary.is-current {
    position: relative;
    font-weight: 700;
}
.shell-nav__summary.is-current {
    color: var(--color-accent-strong);
}
.shell-nav__item.is-active::before,
.shell-nav__subitem.is-active::before,
.shell-nav__summary.is-current::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 58%;
    border-radius: 0 3px 3px 0;
    background: var(--color-accent-strong);
}

/* فوکوسِ کیبوردِ استاندارد روی همهٔ آیتم‌ها و خلاصه‌های منو. */
.shell-nav__item:focus-visible,
.shell-nav__subitem:focus-visible,
.shell-nav__summary:focus-visible {
    outline: 2px solid var(--color-accent-strong);
    outline-offset: -2px;
    border-radius: 0.7rem;
}

.shell-nav__separator {
    width: calc(100% - 1.4rem);
    height: 1px;
    margin: 0.15rem 0.7rem;
    background: linear-gradient(90deg, transparent, rgba(91, 103, 120, 0.22), transparent);
    opacity: 0.82;
}

.shell-nav__separator--level-1 {
    width: calc(100% - 2.2rem);
    margin-inline-start: 0.7rem;
    margin-inline-end: 1.5rem;
}

.shell-nav__separator--level-2 {
    width: calc(100% - 3rem);
    margin-inline-start: 0.7rem;
    margin-inline-end: 2.3rem;
}

.shell-nav__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.95rem;
    height: 0.95rem;
    color: var(--color-accent-strong);
    flex-shrink: 0;
}

.shell-nav__icon svg {
    width: 100%;
    height: 100%;
}

.app-shell__content {
    grid-area: content;
    /* محتوا باید کلِ ستونِ گریدِ خود را پر کند (تمام‌عرض، بدونِ فضای خالیِ بی‌دلیل در عرضِ زیاد).
       سقفِ عرض + margin-inline:auto حذف شد چون روی صفحاتِ دارایِ container-type (مثلِ کارت کالا)
       آیتمِ گرید با مارجینِ خودکار به min-content (~۱۱۳px) جمع می‌شد و صفحه را خراب می‌کرد.
       min-width:0 لازم است تا جدول‌های پهن ستون را بیرون نزنند و فقط داخلِ رَپِرِ خود اسکرولِ افقی بگیرند. */
    padding: var(--space-3);
    min-width: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    direction: rtl;
}

.app-shell__content > section:first-of-type,
.app-shell__content > .stack-lg:first-of-type {
    margin-top: 0;
}

.app-shell__content > .notice + .notice,
.app-shell__content > .notice + section,
.app-shell__content > section + .notice {
    margin-top: var(--space-2);
}

.app-shell__content > .notice {
    margin: 0 0 var(--space-2);
}

.app-shell__content .stack-lg > * + * {
    margin-top: 0.9rem;
}

.app-shell__content > .stack-lg > .card:first-child:not(:only-child) {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.1rem 0 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.app-shell__content > .stack-lg > .card:first-child:not(:only-child) > .eyebrow,
.app-shell__content > .stack-lg > .card:first-child:not(:only-child) > .lede {
    display: none;
}

.app-shell__content > .stack-lg > .card:first-child:not(:only-child) > h2 {
    margin: 0;
    font-size: clamp(1.28rem, 1.7vw, 1.7rem);
}

.app-shell__content > .stack-lg > .card:first-child:not(:only-child) > .button-row {
    gap: 0.55rem;
    margin-top: 0.15rem;
}

.app-shell__content > .stack-lg > .card:first-child:not(:only-child) > .button-row .button,
.app-shell__content > .stack-lg > .card:first-child:not(:only-child) > .button-row .pill {
    padding: 0.42rem 0.78rem;
    font-size: 0.88rem;
}

.guest-shell {
    width: min(100%, 36rem);
}

.guest-shell__intro {
    background: linear-gradient(180deg, rgba(45, 108, 223, 0.08), rgba(45, 108, 223, 0.02)), var(--color-panel);
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: var(--space-3);
}

.module-meta {
    display: grid;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.module-meta div {
    display: grid;
    gap: 0.15rem;
}

.module-meta dt {
    color: var(--color-accent);
    font-size: 0.86rem;
    font-weight: 700;
}

.module-meta dd {
    margin: 0;
}

.toast {
    position: fixed;
    top: calc(var(--shell-sticky-offset) + var(--shell-header-height) - 0.35rem);
    right: var(--space-3);
    z-index: 120;
    min-width: 12rem;
    max-width: min(24rem, calc(100vw - 2rem));
    padding: 0.9rem 1rem;
    border: 1px solid rgba(58, 124, 93, 0.22);
    border-radius: 1rem;
    background: rgba(241, 251, 245, 0.96);
    color: #246043;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 180ms ease, transform 220ms ease;
    direction: rtl;
}

.toast--runtime {
    pointer-events: none;
}

.toast--success {
    border-color: rgba(58, 124, 93, 0.22);
    background: rgba(241, 251, 245, 0.98);
    color: #246043;
}

.toast--error {
    border-color: rgba(190, 78, 78, 0.26);
    background: rgba(253, 243, 243, 0.98);
    color: #a83f3f;
}

.toast__inline-form {
    margin-top: 0.55rem;
}

.toast__inline-form button {
    min-height: 2rem;
    padding: 0.25rem 0.72rem;
    border: 1px solid rgba(5, 150, 105, 0.24);
    border-radius: 0.72rem;
    background: #fff;
    color: #047857;
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 900;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast.is-leaving {
    opacity: 0;
    transform: translateX(120%);
}

.app-shell--embedded {
    overflow-x: hidden;
    background: #fff;
}

.app-shell--embedded .app-shell__frame {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.app-shell--embedded .app-shell__content {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    overflow-x: hidden;
    padding: 0;
}

.app-shell--embedded .shell-header,
.app-shell--embedded .shell-sidebar,
.app-shell--embedded .shell-toolbar {
    display: none !important;
}

.app-shell--embedded .notice {
    margin: 0.75rem;
}

.app-shell--embedded .stack-lg,
.app-shell--embedded .page-sales-show,
.app-shell--embedded .page-product-show,
.app-shell--embedded .person-profile-v2,
.app-shell--embedded .page-waste-show {
    width: 100%;
    max-width: none;
    margin: 0;
    overflow-x: hidden;
}

.app-shell--embedded .card {
    max-width: 100%;
}

.app-shell--embedded table {
    max-width: 100%;
}

.app-shell--embedded .table-shell,
.app-shell--embedded .page-sales-form__table-wrap,
.app-shell--embedded .page-sales-show__money-table-wrap,
.app-shell--embedded .page-product-show__table-shell,
.app-shell--embedded .person-profile-v2__table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.app-shell--embedded table {
    width: 100%;
    min-width: 0 !important;
    table-layout: fixed;
}

.app-shell--embedded th,
.app-shell--embedded td,
.app-shell--embedded th > *,
.app-shell--embedded td > * {
    min-width: 0 !important;
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 960px) {
    .app-shell--guest {
        align-items: flex-start;
        padding: var(--space-3);
    }

    .app-shell__frame {
        grid-template-columns: 1fr;
        grid-template-areas:
            "content";
        padding: var(--space-2);
        direction: rtl;
    }

    .shell-toolbar {
        position: static;
        min-height: auto;
    }
}

/* --- دکمهٔ همبرگرِ هدر (فقط موبایل) --- */
.shell-header__nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex: 0 0 auto;
    border: 1px solid var(--color-border);
    border-radius: 0.7rem;
    background: var(--color-panel);
    color: var(--color-text);
    cursor: pointer;
}
.shell-header__nav-toggle svg { width: 1.25rem; height: 1.25rem; }
.shell-header__nav-toggle:focus-visible { outline: 2px solid var(--color-accent-strong); outline-offset: 2px; }

/* --- دکمهٔ شناورِ منو (جایگزینِ همبرگرِ هدر؛ فقط موبایل) --- */
.shell-menu-fab {
    display: none;
    position: fixed;
    top: 0.75rem;
    inset-inline-end: 0.75rem;
    z-index: 1310;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 0.85rem;
    background: var(--color-panel);
    color: var(--color-text);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
}
.shell-menu-fab svg { width: 1.3rem; height: 1.3rem; }
.shell-menu-fab:focus-visible { outline: 2px solid var(--color-accent-strong); outline-offset: 2px; }

/* --- «خروج»: همیشه آخرین آیتمِ سایدبار، چسبیده به پایین، با استایلِ هشدارِ متمایز --- */
.shell-sidebar__logout {
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 0.4rem;
    margin-block-start: auto;
}
.shell-sidebar__logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    /* کمی بلندتر از آیتم‌های عادی تا «خروج» متمایز و کلیک‌پذیر بماند. */
    padding: 0.46rem 0.6rem;
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: 0.6rem;
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease;
}
.shell-sidebar__logout-btn svg { width: 1rem; height: 1rem; flex: 0 0 auto; }
.shell-sidebar__logout-btn:hover { background: rgba(220, 38, 38, 0.14); border-color: rgba(220, 38, 38, 0.5); }
.shell-sidebar__logout-btn:focus-visible { outline: 2px solid #dc2626; outline-offset: 2px; }
/* ساعتِ ریز کنارِ «خروج»: کوچک‌تر از متن/آیکن است تا ارتفاعِ دکمه را تغییر ندهد. */
.shell-sidebar__clock {
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1;
    opacity: 0.65;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
    padding-inline-start: 0.4rem;
    margin-inline-start: 0.1rem;
    border-inline-start: 1px solid rgba(220, 38, 38, 0.3);
    white-space: nowrap;
}
/* در حالتِ جمع‌شدهٔ دسکتاپ فقط آیکن دیده شود (هماهنگ با بقیهٔ آیتم‌ها). */
.shell-sidebar.is-collapsed .shell-sidebar__logout-btn span,
.shell-sidebar.is-collapsed .shell-sidebar__clock { display: none; }
.shell-sidebar.is-collapsed .shell-sidebar__logout-btn { padding-inline: 0; }

/* دکمهٔ بستنِ منو (فقط در حالتِ کشویِ موبایل دیده می‌شود) */
.shell-sidebar__brand { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.shell-sidebar__close {
    display: none;
    width: 1.65rem; height: 1.65rem;
    border: 0; border-radius: 0.5rem;
    background: rgba(91, 103, 120, 0.12); color: var(--color-text-muted);
    font-size: 1.1rem; line-height: 1; cursor: pointer;
}

/* پس‌زمینهٔ تیرهٔ پشتِ منوی موبایل */
.shell-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1290;
    background: rgba(15, 23, 42, 0.42);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.shell-sidebar-backdrop[hidden] { display: none; }
body.shell-sidebar-open .shell-sidebar-backdrop { opacity: 1; }
body.shell-sidebar-open { overflow: hidden; }

/* --- رفتارِ کشویِ موبایل (بعد از قواعدِ پایه تا ترتیبِ منبع درست باشد) --- */
@media (max-width: 960px) {
    .shell-menu-fab {
        display: inline-flex;
    }

    .shell-sidebar__close {
        display: inline-flex;
    }

    .shell-sidebar {
        position: fixed;
        inset-block: 0;
        /* لنگرِ فیزیکیِ راست (نه inset-inline-end که زیرِ direction:rtl به left می‌رسد
           و کشو را نیمه‌بازِ روی محتوا می‌گذاشت). */
        right: 0;
        left: auto;
        z-index: 1300;
        width: min(20rem, 86vw);
        max-height: 100vh;
        border-radius: 0;
        /* بسته = کاملاً بیرونِ لبهٔ راست. */
        transform: translateX(100%);
        transition: transform 0.24s ease;
        box-shadow: -16px 0 48px rgba(15, 23, 42, 0.22);
        overscroll-behavior: contain;
    }

    body.shell-sidebar-open .shell-sidebar {
        transform: translateX(0);
    }

    /* محتوا هرگز افقی از عرضِ نمایه بیرون نزند (دفاع در عمق؛ جدول‌ها رَپِرِ
       اسکرولِ مخصوصِ خود را دارند، پس clip امن است و sticky را نمی‌شکند). */
    .app-shell__content {
        overflow-x: clip;
        max-width: 100%;
    }
}

@media (min-width: 961px) {
    /* در دسکتاپ هرگز حالتِ کشو فعال نشود. */
    body.shell-sidebar-open { overflow: visible; }
    .shell-sidebar-backdrop { display: none; }
}

/* --- Badge کنارِ آیتم منو --- */
.shell-nav__badge {
    margin-inline-start: auto;
    min-width: 1.2rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: var(--color-accent-strong);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.shell-nav__badge--warn { background: #d97706; }
.shell-nav__badge--danger { background: #dc2626; }
.shell-nav__badge--muted { background: rgba(91, 103, 120, 0.5); }
.shell-nav__summary { position: relative; }

/* --- انیمیشنِ نرمِ بازشدنِ زیرمنو --- */
@media (prefers-reduced-motion: no-preference) {
    details.shell-nav__group[open] > .shell-nav__subnav {
        animation: shellNavReveal 0.18s ease;
    }
}
@keyframes shellNavReveal {
    from { opacity: 0; transform: translateY(-0.25rem); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== جمع‌شدنِ سایدبارِ دسکتاپ + Flyout (نسخهٔ 5.74) ===== */
.shell-sidebar__collapse {
    display: none;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 0.6rem;
    background: rgba(255, 255, 255, 0.7);
    color: var(--color-ink-soft);
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.shell-sidebar__collapse:hover { background: rgba(45, 108, 223, 0.1); color: var(--color-accent-strong); }
.shell-sidebar__collapse svg { width: 1.1rem; height: 1.1rem; }
.shell-sidebar__collapse:focus-visible { outline: 2px solid rgba(45, 108, 223, 0.4); outline-offset: 2px; }

@media (min-width: 961px) {
    .shell-sidebar__collapse { display: inline-flex; }
    body.shell-sidebar-collapsed .shell-sidebar__collapse svg { transform: scaleX(-1); }

    /* ستونِ سایدبار باریک می‌شود (فقط آیکن). */
    body.shell-sidebar-collapsed { --shell-sidebar-width: 4.35rem; }

    body.shell-sidebar-collapsed .shell-sidebar {
        padding: 0.7rem 0.45rem;
        overflow: visible;
    }
    body.shell-sidebar-collapsed .shell-sidebar__brand {
        justify-content: center;
        padding-bottom: 0.6rem;
        border-bottom-color: transparent;
    }
    body.shell-sidebar-collapsed .shell-sidebar__brand h2 { display: none; }

    body.shell-sidebar-collapsed .shell-sidebar .shell-nav { gap: 0.4rem; margin-top: 0.6rem; }

    /* فقط آیکن‌ها: برچسب، badge، فلشِ گروه و زیرمنوی درون‌خطی پنهان. */
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__item > span,
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__summary > span,
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__badge { display: none; }
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__summary::after { display: none; }
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__subnav { display: none; }

    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__item,
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__summary {
        justify-content: center;
        gap: 0;
        padding-inline: 0;
        position: relative;
    }
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__group {
        background: transparent;
        border-color: transparent;
    }

    /* نشانگرِ فعال در حالتِ جمع‌شده: یک نوارِ لبهٔ آغازین. */
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__item.is-active::before,
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__group.is-active > .shell-nav__summary::before,
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__summary.is-current::before {
        content: "";
        position: absolute;
        inset-block: 0.35rem;
        inset-inline-start: 0;
        width: 3px;
        border-radius: 3px;
        background: var(--color-accent-strong);
    }
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__group.is-active > .shell-nav__summary,
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__item.is-active {
        background: rgba(45, 108, 223, 0.12);
        border-radius: 0.8rem;
    }

    /* در حالتِ جمع‌شده، گروهِ دارای flyout هایلایت شود. */
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__group.has-flyout > .shell-nav__summary,
    body.shell-sidebar-collapsed .shell-sidebar .shell-nav__item.has-flyout {
        background: rgba(45, 108, 223, 0.16);
        border-radius: 0.8rem;
    }
}

/* پنلِ Flyout/Popover (به body پیوست می‌شود؛ fixed). */
.shell-flyout {
    position: fixed;
    z-index: 1300;
    min-width: 12rem;
    max-width: min(18rem, calc(100vw - 1.5rem));
    max-height: 80vh;
    overflow-y: auto;
    padding: 0.55rem;
    border: 1px solid var(--color-border);
    border-radius: 0.85rem;
    background: var(--color-panel-strong, #fff);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
    direction: rtl;
    animation: shellFlyoutReveal 0.13s ease;
}
.shell-flyout__close {
    position: absolute;
    inset-inline-start: 0.45rem;
    inset-block-start: 0.4rem;
    width: 1.7rem;
    height: 1.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    background: var(--color-panel, #fff);
    color: var(--color-ink);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}
.shell-flyout__close:hover { background: var(--color-surface-muted, #f1f5f9); }
.shell-flyout--tip .shell-flyout__close { display: none; }
.shell-flyout--tip {
    min-width: 0;
    padding: 0.4rem 0.7rem;
}
.shell-flyout__title {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--color-ink);
    padding: 0.25rem 0.5rem 0.45rem;
    padding-inline-start: 2.2rem; /* جا برای دکمهٔ بستن */
}
.shell-flyout--tip .shell-flyout__title { padding: 0; white-space: nowrap; }
.shell-flyout__list { display: grid; gap: 0.25rem; }
.shell-flyout .shell-nav__subitem,
.shell-flyout .shell-nav__summary {
    padding: 0.55rem 0.6rem;
    border-radius: 0.6rem;
    font-size: 0.9rem;
}
.shell-flyout .shell-nav__subitem.is-active,
.shell-flyout .shell-nav__summary.is-current { background: rgba(45, 108, 223, 0.12); color: var(--color-accent-strong); }
.shell-flyout .shell-nav__summary::after { display: none; }
.shell-flyout .shell-nav__badge { display: inline-flex; }
.shell-flyout a:focus-visible,
.shell-flyout summary:focus-visible { outline: 2px solid rgba(45, 108, 223, 0.45); outline-offset: 1px; }

@keyframes shellFlyoutReveal {
    from { opacity: 0; transform: translateX(6px); }
    to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
    .shell-flyout { animation: none; }
}

/* --- صفحه‌بندیِ مشترکِ حرفه‌ای (partials/_pagination.php) --- */
.app-pager {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 0.6rem 1rem; margin-top: 1rem; padding: 0.6rem 0.2rem;
    border-top: 1px solid var(--color-border, #e5e7eb); direction: rtl;
}
.app-pager__sizes { display: inline-flex; align-items: center; gap: 0.25rem; }
.app-pager__sizes-label { color: var(--color-ink-muted, #94a3b8); font-size: 0.78rem; margin-inline-end: 0.15rem; }
.app-pager__size {
    min-width: 2rem; text-align: center; padding: 0.32rem 0.55rem;
    border: 1px solid var(--color-border, #e5e7eb); border-radius: 0.5rem;
    color: var(--color-ink-muted, #475569); text-decoration: none; font-size: 0.82rem; background: #fff;
}
.app-pager__size:hover { background: var(--color-surface-muted, #f1f5f9); }
.app-pager__size.is-active { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 700; }
.app-pager__nav { display: inline-flex; align-items: center; gap: 0.2rem; flex-wrap: wrap; }
.app-pager__pages { display: inline-flex; align-items: center; gap: 0.2rem; }
.app-pager__current { display: none; color: var(--color-ink-muted, #64748b); font-size: 0.82rem; padding: 0 0.4rem; white-space: nowrap; }
.app-pager__btn, .app-pager__page {
    min-width: 2.1rem; height: 2.1rem; padding: 0 0.45rem;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--color-border, #e5e7eb); border-radius: 0.5rem;
    background: #fff; color: var(--color-ink, #0f172a); text-decoration: none; font-size: 0.9rem; line-height: 1;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.app-pager__btn:hover, .app-pager__page:hover { background: var(--color-surface-muted, #f1f5f9); }
.app-pager__btn:focus-visible, .app-pager__page:focus-visible, .app-pager__size:focus-visible {
    outline: 0; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.app-pager__page.is-active { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 700; }
.app-pager__btn.is-disabled { opacity: 0.4; pointer-events: none; }
.app-pager__gap { padding: 0 0.2rem; color: var(--color-ink-muted, #94a3b8); }
.app-pager__info { color: var(--color-ink-muted, #64748b); font-size: 0.82rem; white-space: nowrap; }
.app-pager--single { justify-content: flex-start; }
/* نسخهٔ compact برای عرضِ کم: شماره‌های میانی پنهان؛ فقط اول/قبلی/«صفحه X از Y»/بعدی/آخر + بازه */
@media (max-width: 640px) {
    .app-pager { justify-content: center; gap: 0.5rem 0.7rem; }
    .app-pager__pages { display: none; }
    .app-pager__current { display: inline-flex; }
    .app-pager__info { width: 100%; text-align: center; }
}

/* ============================================================
   8.85 — «ورود موقت به‌عنوان کاربر» (impersonation)
   ============================================================ */

/* نوارِ ثابتِ بالای محتوا — امبر/کهربایی برای تمایزِ آشکارِ «حالتِ خاص» (نه قرمزِ خطا). */
.impersonation-bar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 0.9rem;
    flex-wrap: wrap;
    padding: 0.42rem 0.85rem;
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    color: #452a04;
    font-weight: 700;
    font-size: 0.82rem;
    border-bottom: 1px solid rgba(120, 53, 15, 0.35);
    box-shadow: 0 3px 10px rgba(120, 53, 15, 0.18);
    direction: rtl;
}
.impersonation-bar__info { display: flex; align-items: center; gap: 0.55rem; min-width: 0; flex: 1 1 auto; }
.impersonation-bar__pill {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.14rem 0.55rem; border-radius: 999px;
    background: rgba(69, 42, 4, 0.92); color: #fde68a; font-size: 0.72rem; white-space: nowrap; flex: 0 0 auto;
}
.impersonation-bar__pill svg { width: 0.9rem; height: 0.9rem; }
.impersonation-bar__text { min-width: 0; line-height: 1.5; }
.impersonation-bar__text strong { font-weight: 800; }
.impersonation-bar__muted { color: #6b4708; font-weight: 600; }
.impersonation-bar__return { margin: 0; flex: 0 0 auto; }
.impersonation-bar__btn {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.32rem 0.75rem; border-radius: 0.55rem; border: 0; cursor: pointer;
    background: #452a04; color: #fff; font: inherit; font-weight: 700; font-size: 0.8rem;
    transition: background 140ms ease;
}
.impersonation-bar__btn svg { width: 1rem; height: 1rem; }
.impersonation-bar__btn:hover { background: #6b4708; }
.impersonation-bar__btn:focus-visible { outline: 2px solid #452a04; outline-offset: 2px; }
@media (max-width: 640px) {
    .impersonation-bar { font-size: 0.76rem; padding: 0.38rem 0.6rem; }
    .impersonation-bar__muted { display: none; }
    .impersonation-bar__btn span { white-space: nowrap; }
}

/* نشانِ «ورود موقت» روی آواتار/متاِ سایدبار. */
.shell-sidebar__avatar.is-impersonating { box-shadow: 0 0 0 2px #f59e0b, 0 0 0 3px rgba(245, 158, 11, 0.35); }
.shell-sidebar__imp-badge {
    display: inline-block; padding: 0.02rem 0.4rem; border-radius: 999px;
    background: #f59e0b; color: #452a04; font-size: 0.66rem; font-weight: 800;
}
.shell-account__admin { display: block; font-size: 0.78rem; color: #6b4708; }
.shell-account__admin strong { color: #452a04; }
.shell-account__return { margin: 0.15rem 0 0.35rem; }
.shell-account__return button {
    display: flex; align-items: center; justify-content: center; gap: 0.4rem; width: 100%;
    padding: 0.42rem 0.6rem; border: 1px solid #f59e0b; border-radius: 0.55rem; cursor: pointer;
    background: #fffbeb; color: #7c4a03; font: inherit; font-weight: 700; font-size: 0.82rem;
    transition: background 140ms ease;
}
.shell-account__return button svg { width: 1rem; height: 1rem; }
.shell-account__return button:hover { background: #fef3c7; }
