﻿/* Cascade layer `app` (UX-361) — application shell and page-level overrides; above core, so no specificity or !important is needed to beat it. Layer order: App.razor <head>.
   Everything in this file sits inside this block; see the end of the file. */
@layer app {

/*
 * Final application UI layer.
 * Loaded after component-scoped styles so every authenticated module follows
 * the supplied Unigate App design instead of retaining legacy page chrome.
 */

html,
body {
    background: var(--ds-bg);
}

/* Shell geometry, defined once (UX-372). Everything that sits under the top bar - drawer, flyout,
   notification panel, user menu, sticky cards, theme.js's sticky-hero check - reads these two instead of
   its own 58/62/66/72/84px. On :root, not .uni-layout, so popovers and theme.js can read them too.
   --uni-sticky-top: where a sticky page element (detail hero, settings nav) parks under the bar. */
:root {
    --uni-appbar-height: 58px;
    --uni-sticky-top: calc(var(--uni-appbar-height) + 8px);
}

/* Authenticated application shell.
   UX-361: the !important left in this section beat MainLayout/NavMenu .razor.css rules, which sit in the
   same `app` layer with a higher specificity (their scope attribute). */
.uni-layout {
    /* MudThemeProvider writes --mud-appbar-height on :root unlayered, so it is re-pointed here, on a
       descendant, where inheritance - not the cascade - decides. */
    --mud-appbar-height: var(--uni-appbar-height);
    min-height: 100dvh;
    background: radial-gradient(circle at 92% 0, var(--ds-primary-softer), transparent 24%), var(--ds-bg);
}

.uni-appbar {
    height: var(--uni-appbar-height);
    min-height: var(--uni-appbar-height);
    padding: 0 16px;
    border: 0;
    border-bottom: 1px solid var(--ds-border);
    background: color-mix(in srgb, var(--ds-surface) 92%, transparent);
    box-shadow: none;
    backdrop-filter: blur(16px);
}

.uni-appbar .mud-toolbar {
    width: 100%;
    height: var(--uni-appbar-height);
    min-height: var(--uni-appbar-height);
    padding: 0;
    gap: 11px;
}

.uni-desktop-leading {
    flex: 0 0 auto;
}

.uni-menu-button {
    width: 38px;
    height: 38px;
    margin: 0;
    border-radius: 10px;
}

.uni-context-block {
    flex: 1 1 auto;
    min-width: 0;
    gap: 10px;
}

/* The flex row, gap and ink came from the old shell's rule in app.css (UX-371 removed that file's dead shell). */
.uni-context-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    height: var(--ds-control-h);
    padding: 0 12px;
    border: 1px solid var(--ds-border);
    border-radius: 11px;
    background: var(--ds-surface);
    color: var(--ds-text-2);
    box-shadow: none;
}

.uni-context-card .mud-icon-root {
    color: var(--ds-text-3);
}

.uni-company-context {
    flex: 0 0 auto;
    width: auto;
}

/* فعال‌سازِ منوی شرکت یک <button> است (UI-SHR-011)، نه MudPaper؛ همین چند خط دکمه را به همان کارتِ
   قبلی برمی‌گرداند. رنگ، حاشیه، ارتفاع و پس‌زمینه از .uni-context-card می‌آیند. */
.uni-company-trigger {
    font: inherit;
    color: inherit;
    text-align: start;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.uni-company-trigger-copy {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.uni-company-trigger-name {
    color: var(--ds-text);
    font-weight: var(--ds-fw-medium);
    line-height: 1.3;
    white-space: nowrap;
}

.uni-company-trigger-code {
    color: var(--ds-faint);
    font-weight: var(--ds-fw-medium);
    line-height: 1.15;
}

/* حلقهٔ فوکوس: دکمه اکنون با Tab می‌رسد و باید دیده شود. */
.uni-company-trigger:focus-visible {
    outline: 2px solid var(--ds-primary);
    outline-offset: 2px;
}

/* نشانِ نخوانده‌های زنگ (UI-SHR-014). رنگ در هر دو تم ثابت است: متن سفید روی #dc2626 نسبت ۴٫۸۳:۱
   دارد، ولی --ds-error در تم تیره (#f87171) با سفید فقط ۲٫۸:۱ می‌دهد. */
.uni-bell-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.uni-bell-badge {
    position: absolute;
    top: 3px;
    inset-inline-end: 3px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    border: 2px solid var(--ds-surface);
    box-sizing: content-box;
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-bold);
    line-height: 17px;
    text-align: center;
    pointer-events: none;
}

.uni-context-value {
    font-size: var(--ds-fs-xs);
}

.uni-context-label {
    font-size: var(--ds-fs-xs);
}

.uni-search-bar {
    max-width: 420px !important;
}

.uni-action-block {
    height: var(--ds-control-h);
    padding: 0;
}

/* UX-363: the app-bar controls share the one control height (company card, action block, user button). */
.uni-user-menu-button,
.uni-user-block {
    min-width: 0 !important;
    height: var(--ds-control-h) !important;
    border-radius: 12px !important;
}

/* تصویرِ کاربر در صفحهٔ جزئیاتِ کاربر (MudAvatar ریشهٔ کامپوننت است و CSSِ ایزولهٔ صفحه به آن نمی‌رسد). */
.user-photo-avatar {
    overflow: hidden;
}

.user-photo-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* تصویرِ کاربر به‌جای آدمک (نوارِ بالا، منوی کاربر، کشوی موبایل، سربرگِ داشبورد): کلِ دایره را پر می‌کند. */
.uni-user-photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.uni-user-avatar-custom,
.uni-user-dropdown-avatar,
.uni-mobile-drawer-avatar {
    overflow: hidden;
}

.uni-user-avatar-custom {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    font-size: var(--ds-fs-xs) !important;
}

.uni-user-avatar-custom .mud-icon-root {
    width: 21px !important;
    height: 21px !important;
    font-size: 21px !important;
}

.uni-user-name {
    font-size: var(--ds-fs-xs);
}

.uni-user-role {
    font-size: var(--ds-fs-xs);
}

.uni-notification-backdrop {
    position: fixed;
    z-index: 1600;
    inset: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: default;
}

.uni-notification-panel {
    position: fixed;
    z-index: 1601;
    top: var(--uni-appbar-height); /* UX-372: flush under the bar, was 66px (an 8px gap) */
    width: min(352px, calc(100vw - 32px));
    overflow: hidden;
    border: 1px solid var(--ds-border);
    border-radius: 10px;
    background: var(--ds-surface);
    box-shadow: var(--ds-shadow-md);
    color: var(--ds-text);
}

html[dir="ltr"] .uni-notification-panel {
    right: 16px;
}

html[dir="rtl"] .uni-notification-panel {
    left: 16px;
}

.uni-notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 0 12px 0 16px;
    border-bottom: 1px solid var(--ds-border-soft);
}

html[dir="rtl"] .uni-notification-panel-header {
    padding: 0 16px 0 12px;
}

.uni-notification-panel-title {
    color: var(--ds-text);
    font-weight: var(--ds-fw-bold);
}

.uni-notification-close {
    color: var(--ds-text-3);
}

.uni-notification-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 184px;
    padding: 24px;
    text-align: center;
}

.uni-notification-empty-icon {
    margin-bottom: 10px;
    color: var(--ds-text-3);
}

.uni-notification-empty-title {
    color: var(--ds-text);
    font-weight: var(--ds-fw-bold);
}

/* Rail, content and flyout move as one (UX-364): the same var(--ds-dur) var(--ds-ease) on .uni-drawer (width),
   .uni-main-content (margin) and .uni-flyout (inset-inline-start, NavFlyout.razor.css). No overshoot curve and
   no will-change - the drawer used to run .36s with a spring from app.css/MainLayout.razor.css and arrive after
   the other two. Reduced motion: see the end of this layer. */
.uni-drawer {
    top: var(--uni-appbar-height);
    height: calc(100dvh - var(--uni-appbar-height));
    border: 0;
    border-inline-end: 1px solid var(--ds-border);
    box-shadow: none;
    transition: width var(--ds-dur) var(--ds-ease), transform var(--ds-dur) var(--ds-ease);
}

.uni-drawer .mud-drawer-content {
    background: radial-gradient(circle at 100% 0, var(--ds-primary-softer), transparent 40%), linear-gradient(180deg, var(--ds-surface), var(--ds-surface-2)) !important;
}

.uni-drawer-frame {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.uni-drawer-nav {
    flex: 1;
    min-height: 0;
}

.uni-drawer-nav > .uni-nav {
    height: 100%;
}

.uni-mobile-drawer-header,
.uni-mobile-drawer-profile,
.uni-mobile-drawer-actions,
.uni-mobile-drawer-scrim,
.core-mobile-filter-toggle,
.dashboard-mobile-quick {
    display: none;
}

/* `margin`, the property MudBlazor itself animates: it sets the physical margin-left/-right per anchor, and
   the shorthand covers both directions without depending on logical-to-physical transition mapping. */
.uni-main-content {
    min-height: 100dvh;
    padding-top: var(--uni-appbar-height);
    background: transparent;
    transition: margin var(--ds-dur) var(--ds-ease);
}

.uni-nav {
    padding: 10px !important;
}

.uni-nav.collapsed {
    padding: 10px 8px !important;
}

.uni-nav.collapsed .uni-rail {
    gap: 4px !important;
}

.uni-nav.collapsed .uni-rail-item {
    width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    border-radius: 11px !important;
}

/* Page and dialog scaffold - moved to core.css (UX-356).
   The `.core-page ...` rules that used to sit here re-styled pages a second time, so the
   same grid, button, card or input looked different in a dialog (outside .core-page). Their final values
   are now the base rules in core.css, shared by pages and the form/confirm dialogs; this file keeps the
   shell and the small-screen overrides below. */

/* Mobile app composition */
.uni-mobile-leading,
.uni-mobile-actions,
.uni-mobile-bottom-nav {
    display: none;
}

/* `screen and` on every small-width block of this file (UX-366): a printed page is narrower than these
   breakpoints, and without it paper got the phone shell and phone grids. */
/* Card-layout grids (UX-357). MudBlazor 9.5 turns a Breakpoint.Sm table into cards with
   `@media (max-width: 960px)` - inclusive - so the rules that style those cards use exactly that width
   (the rest of the small-screen layout above switches at 959.95px). Do not "align" this one.
   `screen and` (UX-366): an A4 page is narrower than 960px, and paper gets the desktop table, not the
   phone cards - the print block at the end of this layer undoes MudBlazor's own card rules there. */
@media screen and (max-width: 960px) {
    body .core-page.core-page .core-data-grid .mud-table-root {
        min-width: 0 !important;
    }

    body .core-page.core-page .core-data-grid .mud-table-toolbar {
        min-height: 62px !important;
        padding: 12px 14px !important;
        border: 1px solid var(--ds-border) !important;
        border-radius: 12px !important;
        background: var(--ds-surface) !important;
        flex-wrap: wrap;
        gap: 6px;
    }

    body .core-page.core-page .core-data-grid .mud-table-toolbar .core-card-subtitle {
        display: none;
    }

    body .core-page.core-page .core-data-grid .mud-table-toolbar .mud-chip {
        height: 26px;
        font-size: 10px;
    }

    body .core-page.core-page .core-data-grid .mud-table-smalldevices-sortselect {
        margin-top: 10px;
        padding: 10px 12px !important;
        border: 1px solid var(--ds-border);
        border-radius: 12px;
        background: var(--ds-surface);
    }

    body .core-page.core-page .core-data-grid .mud-table-container {
        overflow: visible;
    }

    body .core-page.core-page .core-data-grid.mud-sm-table .mud-table-body {
        display: grid;
        gap: 10px;
        padding-top: 10px;
        border: 0;
    }

    body .core-page.core-page .core-data-grid.mud-sm-table .mud-table-row {
        overflow: hidden;
        display: block;
        border: 1px solid var(--ds-border);
        border-radius: 12px;
        background: var(--ds-surface);
        box-shadow: var(--ds-shadow-sm);
    }

    body .core-page.core-page .core-data-grid.mud-sm-table .mud-table-cell {
        min-height: 42px !important;
        height: auto !important;
        padding: 8px 12px !important;
        border-bottom: 1px solid var(--ds-border-soft) !important;
        white-space: normal !important;
        gap: 12px;
    }

    body .core-page.core-page .core-data-grid.mud-sm-table .mud-table-cell:last-child {
        border-bottom: 0 !important;
    }

    body .core-page.core-page .core-data-grid.mud-sm-table .mud-table-cell::before {
        flex: 0 0 34%;
        padding: 0 !important;
        color: var(--ds-faint);
        font-size: 10px;
        font-weight: var(--ds-fw-medium);
        text-align: start;
    }

    body .core-page.core-page .core-data-grid.mud-sm-table .mud-table-cell > * {
        min-width: 0;
    }

    body .core-page.core-page .core-data-grid .mud-table-pagination-toolbar {
        min-height: 58px !important;
        margin-top: 10px;
        padding: 6px 10px !important;
        border: 1px solid var(--ds-border);
        border-radius: 12px;
        background: var(--ds-surface) !important;
        flex-wrap: wrap;
    }

    body .core-page.core-page .core-data-grid .mud-table-pagination-caption {
        font-size: 10.5px;
    }
}

/* (The reduced-motion rule for .core-page moved to the shell motion block at the end of this layer.) */

/* =========================================================
   Application settings page
   کارت‌ها خودشان padding ندارند (core-grid-card فقط برای جدول ساخته شده)،
   پس فاصله‌های داخلی این صفحه اینجا تعریف می‌شود.
   ========================================================= */

.core-page .app-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.core-page .app-settings-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
}

.core-page .app-settings-toolbar-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 260px;
    max-width: 420px;
    flex: 1 1 320px;
}

.core-page .app-settings-toolbar-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 4px;
}

/* دو ستون: فهرستِ ماژول‌ها در سمتِ شروع (در RTL یعنی راست)، تنظیم‌های ماژولِ انتخاب‌شده در
   سمتِ پایان. زیر عرضِ تبلت، فهرست بالای محتوا می‌نشیند و افقی می‌شود. */
.core-page .app-settings-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.core-page .app-settings-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    position: sticky;
    top: var(--uni-sticky-top); /* UX-372: was 84px, 18px lower than the detail hero parks */
}

.core-page .app-settings-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--ds-text);
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.core-page .app-settings-nav-item:hover {
    background: var(--ds-surface-2);
}

.core-page .app-settings-nav-item.is-selected {
    background: var(--ds-surface-inset);
    border-color: var(--ds-primary);
    color: var(--ds-primary);
}

.core-page .app-settings-nav-icon {
    flex: 0 0 auto;
}

.core-page .app-settings-nav-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.core-page .app-settings-nav-title {
    font-size: var(--ds-fs-md);
    font-weight: var(--ds-fw-bold);
    line-height: 1.4;
}

.core-page .app-settings-nav-count {
    font-size: var(--ds-fs-xs);
    color: var(--ds-muted);
}

/* شمارِ تغییرهای ذخیره‌نشدهٔ هر ماژول، تا کاربر بداند در کدام ماژول کاری ناتمام دارد. */
.core-page .app-settings-nav-dirty {
    flex: 0 0 auto;
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--ds-primary);
    color: var(--ds-primary-contrast);
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
    text-align: center;
}

/* جست‌وجوی تنظیم‌ها (UX-260): ماژولِ بی‌نتیجه کم‌رنگ می‌شود ولی کلیک‌پذیر می‌ماند، و شمارِ نتیجه‌های هر
   ماژول کنار نامش می‌نشیند — هم‌شکلِ نشانِ تغییرهای ذخیره‌نشده ولی با رنگِ خنثی تا با آن اشتباه نشود. */
/* UX-351: was opacity .5 (title 3.39:1). The faint text colour instead: 5.17 light / 5.46 dark. */
.core-page .app-settings-nav-item.is-no-match:not(.is-selected) {
    color: var(--ds-faint);
}

.core-page .app-settings-nav-match {
    flex: 0 0 auto;
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid var(--ds-primary);
    color: var(--ds-primary);
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
    text-align: center;
}

.core-page .app-settings-search-empty {
    margin-bottom: 14px;
}

.core-page .app-settings-content {
    padding: 18px 22px 22px;
    min-height: 320px;
}

.core-page .app-settings-content-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--ds-border-soft);
}

.core-page .app-settings-content-icon {
    color: var(--ds-primary);
    font-size: 1.8rem;
}

.core-page .app-settings-content-title {
    font-weight: var(--ds-fw-bold);
}

.core-page .app-settings-content-subtitle {
    color: var(--ds-muted);
}

.core-page .app-settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.core-page .app-settings-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 15px 18px;
    border: 1px solid var(--ds-border-soft);
    border-radius: 16px;
    background: var(--ds-surface);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.core-page .app-settings-item:hover {
    border-color: var(--ds-border);
    box-shadow: var(--ds-shadow-sm);
}

/* وضعیت هر تنظیم با یک نوار رنگی در لبهٔ شروع کارت خوانده می‌شود، نه فقط از روی کلید. */
.core-page .app-settings-item.is-on {
    border-inline-start: 3px solid var(--ds-primary);
}

.core-page .app-settings-item.is-off {
    border-inline-start: 3px solid var(--ds-border-strong);
    background: var(--ds-surface-2);
}

/* تغییر ذخیره‌نشده باید پیش از زدن «ذخیره» دیده شود. */
.core-page .app-settings-item.is-dirty {
    border-color: var(--ds-primary);
    box-shadow: var(--ds-shadow-primary);
}

.core-page .app-settings-item-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.core-page .app-settings-item-title {
    font-size: var(--ds-fs-md);
    font-weight: var(--ds-fw-medium);
    line-height: 1.6;
    color: var(--ds-text);
}

/* عنوان و نشانِ «سفارشی‌شده» در یک خط (UX-262). */
.core-page .app-settings-item-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
}

.core-page .app-settings-item-badge {
    margin: 0;
    height: 20px;
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
}

/* «پیش‌فرض: …»، آیکنِ کلیدِ فنی و آخرین تغییر در یک ردیفِ ریز. */
.core-page .app-settings-item-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 10px;
}

.core-page .app-settings-item-default {
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
    color: var(--ds-muted);
}

/* کلید فنی می‌ماند — پشتیبانی و لاگ با همین نام کار می‌کنند — ولی فقط در راهنمای آیکن، کپی‌شدنی. */
.core-page .app-settings-item-key-btn {
    padding: 2px;
    color: var(--ds-muted);
}

.core-page .app-settings-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-inline-start: -6px;
}

/* راهنما بیرون از .core-page (در لایهٔ popover) رسم می‌شود، پس پیشوندِ صفحه ندارد. */
.app-settings-key-tooltip-key {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--ds-fs-xs);
    overflow-wrap: anywhere;
}

.app-settings-key-tooltip-hint {
    font-size: var(--ds-fs-xs); /* UX-351: opacity .85 removed — the smaller size already sets it apart */
}

.core-page .app-settings-item-desc {
    font-size: var(--ds-fs-sm);
    line-height: 1.7;
    color: var(--ds-muted);
}

/* UX-351: muted at opacity .8 was 3.41:1; solid --ds-faint is 5.17 light / 5.46 dark on the card. */
.core-page .app-settings-item-meta {
    font-size: var(--ds-fs-xs);
    color: var(--ds-faint);
}

.core-page .app-settings-item-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}

.core-page .app-settings-item-toggle .mud-switch {
    margin: 0;
}

/* تنظیمِ غیردوحالته کنترلِ عریض‌تری می‌خواهد؛ کلید یک آیکن است و دراپ‌داون یک جمله.
   عرضِ ثابت است تا کارت‌های یک ستون با هم هم‌تراز بمانند. */
.core-page .app-settings-item-input {
    min-width: 220px;
    max-width: 260px;
}

.core-page .app-settings-item-state {
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
    color: var(--ds-muted);
}

.core-page .app-settings-item.is-on .app-settings-item-state {
    color: var(--ds-primary);
}

/* ---- زیرعنوانِ جریان در «تنظیمات وب‌سرویس» ----------------------------------------------------
   فقط تنظیم‌های گروه‌دار زیرعنوان می‌گیرند؛ دسته‌های دیگر همان فهرستِ بی‌زیرعنوان‌اند. */
.core-page .app-settings-group-title {
    margin-top: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--ds-border-soft);
    font-size: var(--ds-fs-md);
    font-weight: var(--ds-fw-bold);
    color: var(--ds-text);
}

.core-page .app-settings-group-title:first-child {
    margin-top: 0;
}

/* ---- انتخابِ چندگانهٔ مرتب (منبعِ تاریخِ وب‌سرویس) -------------------------------------------
   کنترل بلندتر از یک دراپ‌داون است؛ کارت زیرِ متن ستونی می‌شود و کنترل عرضِ کارت را می‌گیرد. */
.core-page .app-settings-item.is-multi {
    flex-direction: column;
    align-items: stretch;
}

.core-page .app-settings-item.is-multi .app-settings-item-toggle {
    align-items: flex-start;
    width: 100%;
}

.core-page .ordered-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.core-page .ordered-choice-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.core-page .ordered-choice-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.core-page .ordered-choice-chip {
    margin: 0;
}

/* شمارهٔ اولویت، پیش از عنوانِ منبع: دایرهٔ کوچکِ هم‌رنگِ چیپ. */
.core-page .ordered-choice-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    margin-inline-end: 8px;
    border-radius: 999px;
    background: var(--ds-primary);
    color: var(--ds-primary-contrast);
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
}

.core-page .ordered-choice-title {
    font-size: var(--ds-fs-sm);
    font-weight: var(--ds-fw-medium);
}

.core-page .ordered-choice-actions {
    display: inline-flex;
    align-items: center;
}

.core-page .ordered-choice-fallback {
    font-size: var(--ds-fs-xs);
    line-height: 1.7;
    color: var(--ds-muted);
}


/* ---- گزینهٔ دوستونیِ انتخابگرهای جست‌وجویی -------------------------------------------------
   عنوان سمتِ متن و برچسبِ کاربرد سمتِ دیگر، تا در فهرستی که چند کاربرد را با هم نشان می‌دهد
   معلوم باشد هر گزینه مالِ کدام است. با width:100% کار می‌کند چون گزینهٔ MudBlazor خودش
   flex است و بدون آن، برچسب به عنوان می‌چسبد. */
.core-lookup-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.core-lookup-option-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.core-lookup-option-tag {
    flex: 0 0 auto;
    padding: 2px 8px;
    border: 1px solid var(--ds-border);
    border-radius: 999px;
    background: var(--ds-surface-2);
    color: var(--ds-muted);
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
    white-space: nowrap;
}

/* صفحهٔ «پیدا نشد». کارت وسط صفحه می‌ایستد چون این صفحه محتوایی برای تراز کردن با آن ندارد. */
.core-page.uni-notfound {
    display: grid;
    place-items: center;
    min-height: 60dvh;
}

.core-page.uni-notfound .uni-notfound-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 40px 36px;
    max-width: 520px;
}

/* ---------------------------------------------------------------------------
   تاگل فقط با کلیک روی خودِ تاگل عوض می‌شود.

   MudSwitch ریشه‌اش یک <label> است که هم دکمه و هم متن را در خود دارد، پس مرورگر
   کلیک روی هر جای آن را به checkbox می‌رساند. داخل یک MudItem تمام‌عرض این یعنی
   کل ردیف قابل کلیک می‌شود و کاربر با کلیکِ تصادفی «پرداخت توسط پیمانکار» را
   روشن و خاموش می‌کند بی‌آنکه بفهمد.

   قاعده روی خودِ <label> می‌نشیند، نه روی متن: بستنِ pointer-events فقط روی متن
   کافی نیست، چون کلیک از متن رد می‌شود و به <label> می‌رسد و مرورگر همان را به
   checkbox می‌رساند — یعنی متن باز هم تاگل را عوض می‌کند. پس کل label از دسترسِ
   اشاره‌گر خارج و فقط خودِ کلید دوباره برگردانده می‌شود.

   تمرکز با صفحه‌کلید دست‌نخورده می‌ماند: pointer-events روی Tab و Space اثر ندارد.

   این قاعده عمداً به .core-page محدود نشده — دیالوگ‌ها بیرون از آن رندر می‌شوند و
   همین صفحهٔ ساخت لود یک دیالوگ است.
   --------------------------------------------------------------------------- */
label.mud-switch {
    pointer-events: none;
}

label.mud-switch .mud-switch-span {
    pointer-events: auto;
}

/* ---------------------------------------------------------------------------
   ورودیِ آزمونِ قبول‌نشده در کنترل کیفیت.

   پارامترِ Error روی MudSelect در این نسخه کلاسِ mud-input-error را نمی‌گذارد، پس
   قاعدهٔ خودِ MudBlazor هم فعال نمی‌شود و «رد» هیچ نشانهٔ دیداری نمی‌گرفت. این کلاس
   مستقیم روی همان لایهٔ خطِ دور می‌نشیند.

   حالتِ :hover جداگانه آمده چون core.css قاعدهٔ .core-input:hover را با !important دارد و
   بدون آن، خطِ قرمز زیر نشانگرِ ماوس آبی می‌شد.

   بیرون از .core-page تعریف شده چون دیالوگ‌ها آنجا رندر نمی‌شوند.
   --------------------------------------------------------------------------- */
.core-input.uni-input-failed .mud-input-outlined-border,
.core-input.uni-input-failed:hover .mud-input-outlined-border {
    border-color: var(--mud-palette-error);
    border-width: 2px;
}


/* ===== صفحهٔ خطای تولید (/Error) و نوارِ خطای مدار (UX-007, UX-008) ===== */
.uni-error-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 36px 24px;
    text-align: center;
}

.uni-error-icon {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: var(--ds-error-soft);
    color: var(--ds-error);
}

.uni-error-title {
    margin: 0;
    font-size: var(--ds-fs-xl);
    font-weight: var(--ds-fw-bold);
    color: var(--ds-text);
}

.uni-error-text {
    margin: 0;
    max-width: 480px;
    color: var(--ds-muted);
    font-size: var(--ds-fs-sm);
    line-height: 1.8;
}

.uni-error-request {
    margin: 0;
    font-size: var(--ds-fs-xs);
    color: var(--ds-muted);
}

.uni-error-request code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--ds-surface-2);
    font-size: var(--ds-fs-xs);
    user-select: all;
}

.uni-error-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
}

.uni-error-btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border: 1px solid var(--ds-border);
    border-radius: 10px;
    background: var(--ds-surface);
    color: var(--ds-text);
    font-size: var(--ds-fs-sm);
    font-weight: var(--ds-fw-medium);
    text-decoration: none;
}

.uni-error-btn--primary {
    border-color: var(--ds-primary);
    background: var(--ds-primary);
    color: var(--ds-primary-contrast);
}

.uni-error-dev {
    margin-top: 20px;
    padding: 14px 16px;
    border: 1px dashed var(--ds-border);
    border-radius: 10px;
    text-align: start;
    font-size: var(--ds-fs-xs);
    color: var(--ds-muted);
}

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 4000;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    background: var(--ds-warning-soft);
    color: var(--ds-text);
    border-top: 2px solid var(--ds-warning);
    box-shadow: var(--ds-shadow-lg); /* UX-367: was a fixed light-theme rgba that vanished on the dark surface */
    font-family: inherit; /* UX-353: was var(--uni-font), a token that was never defined */
    font-size: var(--ds-fs-sm);
}

#blazor-error-ui .reload {
    font-weight: var(--ds-fw-medium);
    color: var(--ds-primary-strong);
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    margin-inline-start: auto;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}


/* یک کنترل برای جمع/باز کردنِ ریل روی دسکتاپ: همبرگرِ نوار بالا. پایینیِ «جمع کردن منو» همان کار را تکرار می‌کرد (UX-039). */
@media (min-width: 960px) {
    .uni-nav-footer {
        display: none !important;
    }
}

/* ===== نوارِ پیشرفتِ بالای صفحه (UX-047) ===== */
.uni-top-progress {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 3600; /* UX-383: above the busy overlay (3500), below #blazor-error-ui (4000); was 2100 */
    height: 3px;
    overflow: hidden;
    pointer-events: none;
    background: color-mix(in srgb, var(--ds-primary) 16%, transparent);
}

.uni-top-progress-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    border-radius: 3px;
    background: var(--ds-primary);
    animation: uni-top-progress 1.1s ease-in-out infinite;
}

html[dir="rtl"] .uni-top-progress-bar {
    animation-direction: reverse;
}

@keyframes uni-top-progress {
    from { left: -40%; }
    to { left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .uni-top-progress-bar {
        animation-duration: 2.4s;
    }
}

/* ===== هشدارِ Caps Lock (UX-044) ===== */
.uni-capslock-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
    color: var(--ds-warning-strong);
}

/* display:flex بالا ویژگیِ hidden را بی‌اثر می‌کرد. */
.uni-capslock-hint[hidden] {
    display: none;
}

/* ===== شرایطِ رمزِ تازه در نمایه (UX-046) ===== */
.uni-password-rules {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--ds-fs-xs);
    color: var(--ds-text-2);
}

.uni-password-rules li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.uni-password-rules .mud-icon-root {
    color: var(--ds-faint);
}

.uni-password-rules li.is-met .mud-icon-root {
    color: var(--ds-success);
}

/* ===== کدِ صفحه در پیامِ «دسترسی ندارید» (UX-045) ===== */
.uni-form-code {
    padding: 2px 8px;
    border: 1px solid var(--ds-border-soft);
    border-radius: 6px;
    background: var(--ds-surface-2);
    font-family: Consolas, "Courier New", monospace;
    font-size: var(--ds-fs-xs);
    user-select: all;
}

/* ===== حالتِ خطای گرید (UX-058) ===== */
.core-grid-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-bottom: 16px;
}

/* ===== بازهٔ تاریخ در کارتِ فیلتر (UX-059) ===== */
.core-date-range > * {
    flex: 1 1 0;
    min-width: 0;
}

.core-date-range > .core-date-range-preset {
    flex: 0 0 180px;
}

/* ===== کلیدِ هم‌قدِ فیلدها و سرتیترِ بخش در کارتِ فیلتر (گزارش جامع ارسال‌ها) =====
   کلیدِ بی‌قاب زیرِ برچسب، کنارِ کشویی‌ها و کادرها نیمه‌خالی دیده می‌شد؛ این قاب هم‌قد و هم‌حاشیهٔ فیلدهاست.
   متن کلید را نمی‌زند — فقط خودِ کلید (قاعدهٔ toggle). */
.core-filter-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: var(--ds-control-h);
    padding: 0 12px 0 4px;
    border: 1px solid var(--ds-border-strong);
    border-radius: 11px;
    background: var(--ds-surface);
    color: var(--ds-text);
    font-size: var(--ds-fs-sm);
}

.core-filter-switch .mud-switch {
    margin: 0;
}

.core-filter-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px dashed var(--ds-border-soft);
    color: var(--ds-muted);
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
}

/* ===== خلاصهٔ فیلترهای فعال در کارتِ جمع‌شده (UX-068) ===== */
.core-filter-active {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}

.core-filter-active-count {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--ds-primary-soft);
    color: var(--ds-primary-strong);
    font-size: var(--ds-fs-xs);
    font-weight: var(--ds-fw-medium);
}

.core-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 22rem;
    padding: 2px 10px;
    border: 1px solid var(--ds-border);
    border-radius: 999px;
    background: var(--ds-surface-2);
    font-size: var(--ds-fs-xs);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.core-filter-chip strong {
    font-weight: var(--ds-fw-medium);
    color: var(--ds-text-2);
}

.core-filter-chip strong::after {
    content: ':';
}

/* ---------------------------------------------------------------------------
   کارتِ هویتِ صفحهٔ جزئیات بالای صفحه می‌چسبد و وقتی از جای خودش بیرون رفت جمع می‌شود: شماره، وضعیت و
   دکمه‌ها هنگامِ خواندنِ ردیف‌ها در دید می‌مانند (UX-196). کلاسِ is-stuck را theme.js (unigateStickyHero)
   می‌گذارد. فقط دسکتاپ.
   --------------------------------------------------------------------------- */
@media screen and (min-width: 960px) {
    .core-page .core-hero-card {
        position: sticky;
        top: var(--uni-sticky-top); /* UX-372; theme.js reads the same variable */
        z-index: 6;
    }

    .core-page .core-hero-card.is-stuck {
        padding: 8px 16px;
        box-shadow: var(--ds-shadow);
    }

    .core-page .core-hero-card.is-stuck .core-hero-icon,
    .core-page .core-hero-card.is-stuck .core-hero-kicker,
    .core-page .core-hero-card.is-stuck .core-hero-subtitle {
        display: none;
    }

    .core-page .core-hero-card.is-stuck .core-hero-title {
        font-size: var(--ds-fs-lg);
    }

    .core-page .core-hero-card.is-stuck .core-hero-content {
        flex-wrap: nowrap;
        gap: 10px;
    }
}

/* ---------------------------------------------------------------------------
   Shell motion and reduced motion (UX-364).
   Spelled out rather than left to core.css's global .001ms rule: with reduced motion the rail, the
   content margin and the flyout jump straight to their new place, and pages do not fade in.
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .uni-drawer,
    .uni-main-content,
    .uni-flyout {
        transition: none;
    }

    .core-page {
        animation: none;
    }
}

/* ---------------------------------------------------------------------------
   Print (UX-366). A list or a record on paper: no top bar, rail, flyout, bottom bar or popups (hidden in
   mud.overrides below, because several are MudStacks with MudBlazor's !important .d-flex), no filter card,
   page or grid buttons, pager or column menus; every row of the loaded page instead of the ~10-row scroll
   box; no shadows; light colours. The light theme itself comes from theme.js, which switches
   data-theme to light on beforeprint and back on afterprint.
   --------------------------------------------------------------------------- */
@media print {
    @page {
        margin: 12mm 10mm;
    }

    html,
    body {
        background: var(--ds-surface);
        color-scheme: light;
    }

    /* MudBlazor writes its palette on :root, unlayered, and keeps the dark values while the theme toggle says
       dark; set on <body> they inherit down instead, so Mud surfaces print on the (light) tokens. */
    body {
        --mud-palette-background: var(--ds-surface);
        --mud-palette-surface: var(--ds-surface);
        --mud-palette-text-primary: var(--ds-text);
        --mud-palette-text-secondary: var(--ds-text-2);
        --mud-palette-lines-default: var(--ds-border);
        --mud-palette-table-lines: var(--ds-border);
        --mud-palette-divider: var(--ds-border);
    }

    .uni-layout {
        min-height: 0;
        background: none;
    }

    .uni-main-content {
        min-height: 0;
        margin: 0;
        padding: 0;
        transition: none;
    }

    .core-page {
        max-width: none;
        padding: 0;
        animation: none;
    }

    /* The fixed-height scroll box becomes the whole table, so every loaded row reaches the paper. */
    .core-data-grid .mud-table-container {
        max-height: none;
        overflow: visible;
    }

    .core-data-grid .mud-table-root {
        min-width: 0;
    }

    /* Sticky header cells and the pinned checkbox column have nothing to stick to on paper. */
    .core-data-grid .mud-table-cell {
        position: static;
    }

    /* MudBlazor's own card layout (max-width: 960px) also matches a page narrower than 960px; put the
       table back. The layer, not specificity, beats MudBlazor's rules here. */
    .core-data-grid .mud-table-head .mud-table-row,
    .core-data-grid .mud-table-row {
        display: table-row;
    }

    .core-data-grid .mud-table-head {
        display: table-header-group; /* repeats the column titles on every printed page */
    }

    .core-data-grid .mud-table-foot {
        display: table-footer-group;
    }

    .core-data-grid .mud-table-cell {
        display: table-cell;
    }

    .core-data-grid .mud-table-cell::before {
        content: none;
    }

    .core-data-grid .mud-table-row,
    .core-summary-card,
    .core-hero-card,
    .core-details-card {
        break-inside: avoid;
    }

    .core-page .core-hero-card {
        position: static;
    }
}

} /* end @layer app */

/* mud.overrides (UX-361): small-screen rules that have to beat a MudBlazor !important utility (MudStack
   renders .d-flex). Why they cannot live in the app layer: see the mud.overrides block at the end of core.css.
   The page header, filter footer and hero stacking are there too. */
@layer mud.overrides {
    /* Print (UX-366) - what never belongs on paper. Here, not in the app layer, because the page actions,
       filter footer and app-bar blocks are MudStacks whose .d-flex !important only this layer can beat. */
    @media print {
        .uni-appbar,
        .uni-drawer,
        .uni-mobile-drawer-scrim,
        .uni-mobile-bottom-nav,
        .uni-flyout,
        .uni-flyout-scrim,
        .uni-notification-backdrop,
        .uni-notification-panel,
        .uni-user-dropdown-backdrop,
        .uni-user-dropdown,
        .uni-palette-scrim,
        .uni-palette,
        .uni-top-progress,
        #blazor-error-ui,
        #mud-snackbar-container,
        .core-page-actions,
        .core-mobile-filter-toggle,
        .core-filter-card,
        .core-grid-actions,
        .core-grid-tab:not(.is-active),
        .core-action-button,
        .core-action-toolbar,
        .core-details-actions,
        .core-side-actions,
        .core-comment-actions,
        .core-data-grid .mud-table-toolbar .mud-chip[title],
        .core-data-grid .mud-table-smalldevices-sortselect,
        .core-data-grid .mud-table-pagination,
        .core-data-grid .column-options,
        .core-data-grid .mud-checkbox {
            display: none !important;
        }

        *,
        *::before,
        *::after {
            box-shadow: none !important;
            text-shadow: none !important;
        }
    }
}
