/* =============================================================================
   گزارش‌های ماتریس سالن-هفته (موجودی / تلفات)
   ============================================================================= */

.swm-page {
    padding-bottom: 1.5rem;
}

.swm-header-icon {
    color: var(--theme-primary) !important;
}

.swm-header-title {
    font-weight: 700 !important;
}

.swm-filter-card {
    border-radius: 12px !important;
    border: 1px solid var(--ps-border, #e2e8f0);
}

.swm-filter-label {
    font-family: 'IRANSans', sans-serif;
    font-size: 0.75rem;
    color: var(--theme-text-secondary);
    margin-bottom: 4px;
}

.swm-week-sliders {
    gap: 0.5rem;
}

.swm-kpi-grid {
    margin-bottom: 0.75rem;
}

.swm-kpi {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.75rem 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--ps-border, #e2e8f0);
    background: var(--ps-surface, #fff);
    box-shadow: var(--ps-shadow-sm);
    min-height: 76px;
}

.swm-kpi-label {
    font-family: 'IRANSans', sans-serif;
    font-size: 0.68rem;
    color: var(--theme-text-secondary);
}

.swm-kpi-value {
    font-family: 'IRANSans', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--theme-text-primary);
}

.swm-kpi--female { border-top: 3px solid #00897b; }
.swm-kpi--female .mud-icon-root { color: #00897b !important; }

.swm-kpi--male { border-top: 3px solid #1565c0; }
.swm-kpi--male .mud-icon-root { color: #1565c0 !important; }

.swm-kpi--balance { border-top: 3px solid #2e7d32; }
.swm-kpi--balance .mud-icon-root { color: #2e7d32 !important; }

.swm-kpi--mortality { border-top: 3px solid #c62828; }
.swm-kpi--mortality .mud-icon-root { color: #c62828 !important; }

.swm-kpi--weeks { border-top: 3px solid #6a1b9a; }
.swm-kpi--weeks .mud-icon-root { color: #6a1b9a !important; }

.swm-kpi--salons { border-top: 3px solid #5d4037; }
.swm-kpi--salons .mud-icon-root { color: #5d4037 !important; }

.swm-kpi--display { border-top: 3px solid #00796b; }
.swm-kpi--display .mud-icon-root { color: #00796b !important; }

.swm-table-card {
    border-radius: 12px !important;
    border: 1px solid var(--ps-border, #e2e8f0);
    overflow: hidden;
}

.swm-table-toolbar {
    padding: 0.5rem 0.75rem 0.75rem;
    border-bottom: 1px solid var(--ps-border, #e2e8f0);
}

.swm-table-toolbar-title {
    font-weight: 700 !important;
    color: var(--theme-primary) !important;
}

.swm-grid-wrap {
    width: 100%;
    height: min(72dvh, calc(100dvh - 300px));
    min-height: 320px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.swm-th-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 8px 6px;
    box-sizing: border-box;
    text-align: center;
    background: transparent !important;
}

.swm-th-sub {
    font-family: 'IRANSans', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    color: #fff !important;
}

/* ─── هدر: رنگ ثابت — override تم و general-datagrid-class ─── */
.swm-page .general-datagrid-class.swm-datagrid-colored .mud-table-head,
.general-datagrid-class.swm-datagrid-colored .mud-table-head {
    background: transparent !important;
    box-shadow: none !important;
}

.general-datagrid-class.swm-datagrid-colored .mud-table .mud-table-head th,
.general-datagrid-class.swm-datagrid-colored .mud-table .mud-table-head .mud-th,
.general-datagrid-class.swm-datagrid-colored .mud-table .mud-table-head .mud-table-cell,
.swm-datagrid-colored .mud-table .mud-table-head th,
.swm-datagrid-colored .mud-table .mud-table-head .mud-th,
.swm-datagrid-colored .mud-table .mud-table-head .mud-table-cell {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    vertical-align: middle !important;
    color: #fff !important;
    background: #00897b !important;
    background-color: #00897b !important;
    background-image: none !important;
}

.general-datagrid-class.swm-datagrid-colored .mud-table-head .swm-th-sub,
.general-datagrid-class.swm-datagrid-colored .mud-table-head .swm-th-stack *,
.swm-datagrid-colored .mud-table-head .swm-th-sub,
.swm-datagrid-colored .mud-table-head .swm-th-stack * {
    color: #fff !important;
}

/* ستون سالن */
.general-datagrid-class.swm-datagrid-colored .mud-table-head th:has(.swm-th-sub--salon),
.general-datagrid-class.swm-datagrid-colored .mud-table-head .mud-table-cell:has(.swm-th-sub--salon),
.swm-datagrid-colored .mud-table-head th:has(.swm-th-sub--salon),
.swm-datagrid-colored .mud-table-head .mud-table-cell:has(.swm-th-sub--salon) {
    background: #455a64 !important;
    background-color: #455a64 !important;
    background-image: none !important;
}

/* ستون‌های هفته — مرغ */
.general-datagrid-class.swm-datagrid-colored.swm-sex-female .mud-table-head th:has(.swm-th-sub--week),
.general-datagrid-class.swm-datagrid-colored.swm-sex-female .mud-table-head .mud-table-cell:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-sex-female .mud-table-head th:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-sex-female .mud-table-head .mud-table-cell:has(.swm-th-sub--week) {
    background: #00897b !important;
    background-color: #00897b !important;
    background-image: none !important;
}

/* ستون‌های هفته — خروس */
.general-datagrid-class.swm-datagrid-colored.swm-sex-male .mud-table-head th:has(.swm-th-sub--week),
.general-datagrid-class.swm-datagrid-colored.swm-sex-male .mud-table-head .mud-table-cell:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-sex-male .mud-table-head th:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-sex-male .mud-table-head .mud-table-cell:has(.swm-th-sub--week) {
    background: #1565c0 !important;
    background-color: #1565c0 !important;
    background-image: none !important;
}

/* پیش‌فرض هفته اگر کلاس جنسیت نبود */
.general-datagrid-class.swm-datagrid-colored .mud-table-head th:has(.swm-th-sub--week),
.general-datagrid-class.swm-datagrid-colored .mud-table-head .mud-table-cell:has(.swm-th-sub--week),
.swm-datagrid-colored .mud-table-head th:has(.swm-th-sub--week),
.swm-datagrid-colored .mud-table-head .mud-table-cell:has(.swm-th-sub--week) {
    background: #00897b !important;
    background-color: #00897b !important;
    background-image: none !important;
}

/* چک‌باکس مقایسه */
.general-datagrid-class.swm-datagrid-colored .mud-table-head th:has(.swm-th-sub--select),
.general-datagrid-class.swm-datagrid-colored .mud-table-head .mud-table-cell:has(.swm-th-sub--select),
.swm-datagrid-colored .mud-table-head th:has(.swm-th-sub--select),
.swm-datagrid-colored .mud-table-head .mud-table-cell:has(.swm-th-sub--select) {
    background: #37474f !important;
    background-color: #37474f !important;
    background-image: none !important;
}

/* ماتریس تلفات: هدر هفته‌ها قرمز-بنفش */
.general-datagrid-class.swm-datagrid-colored.swm-matrix-mortality.swm-sex-female .mud-table-head th:has(.swm-th-sub--week),
.general-datagrid-class.swm-datagrid-colored.swm-matrix-mortality.swm-sex-female .mud-table-head .mud-table-cell:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-matrix-mortality.swm-sex-female .mud-table-head th:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-matrix-mortality.swm-sex-female .mud-table-head .mud-table-cell:has(.swm-th-sub--week) {
    background: #c62828 !important;
    background-color: #c62828 !important;
    background-image: none !important;
}

.general-datagrid-class.swm-datagrid-colored.swm-matrix-mortality.swm-sex-male .mud-table-head th:has(.swm-th-sub--week),
.general-datagrid-class.swm-datagrid-colored.swm-matrix-mortality.swm-sex-male .mud-table-head .mud-table-cell:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-matrix-mortality.swm-sex-male .mud-table-head th:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-matrix-mortality.swm-sex-male .mud-table-head .mud-table-cell:has(.swm-th-sub--week) {
    background: #6a1b9a !important;
    background-color: #6a1b9a !important;
    background-image: none !important;
}

.general-datagrid-class.swm-datagrid-colored.swm-matrix-mortality .mud-table-head th:has(.swm-th-sub--week),
.general-datagrid-class.swm-datagrid-colored.swm-matrix-mortality .mud-table-head .mud-table-cell:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-matrix-mortality .mud-table-head th:has(.swm-th-sub--week),
.swm-datagrid-colored.swm-matrix-mortality .mud-table-head .mud-table-cell:has(.swm-th-sub--week) {
    background: #c62828 !important;
    background-color: #c62828 !important;
    background-image: none !important;
}

[data-theme="dark"] .general-datagrid-class.swm-datagrid-colored .mud-table-head th,
[data-theme="dark"] .general-datagrid-class.swm-datagrid-colored .mud-table-head .mud-table-cell,
.mud-theme-dark .general-datagrid-class.swm-datagrid-colored .mud-table-head th,
.mud-theme-dark .general-datagrid-class.swm-datagrid-colored .mud-table-head .mud-table-cell {
    background-image: none !important;
}

.swm-datagrid-colored .mud-table-body .mud-table-cell {
    text-align: center !important;
    vertical-align: middle !important;
}

.swm-cell-center {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
}

.swm-salon-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    min-width: 0;
    padding: 2px 4px;
}

/* ماتریس تلفات: عرض سالن بر اساس نام */
.swmm-page .swm-salon-cell {
    min-width: unset;
    width: max-content;
}

.swm-salon-name {
    flex: 1;
    text-align: right;
    font-weight: 600;
}

.swm-footer-salon {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 4px 8px;
    background-color: #5d4037 !important;
    color: #fff !important;
    font-weight: 700;
}

.swm-footer-salon strong,
.swm-footer-salon .mud-typography {
    color: #fff !important;
}

.swm-footer-num {
    text-align: center;
    width: 100%;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.swmm-page .swm-footer-num {
    font-size: 1.05rem !important;
    font-weight: 800 !important;
}

@media screen {
    .swm-datagrid-colored .mud-data-grid-footer td {
        text-align: center !important;
        vertical-align: middle !important;
        font-weight: 700;
        background-color: #eceff1 !important;
    }

    [data-theme="dark"] .swm-datagrid-colored .mud-data-grid-footer td,
    .mud-theme-dark .swm-datagrid-colored .mud-data-grid-footer td {
        background-color: color-mix(in srgb, var(--mud-palette-error, #c62828) 8%, var(--mud-palette-surface, #1e1e1e)) !important;
    }

    [data-theme="dark"] .swm-datagrid-colored .mud-data-grid-footer .swm-footer-num,
    [data-theme="dark"] .swm-datagrid-colored .mud-data-grid-footer .swmm-footer-week,
    .mud-theme-dark .swm-datagrid-colored .mud-data-grid-footer .swm-footer-num,
    .mud-theme-dark .swm-datagrid-colored .mud-data-grid-footer .swmm-footer-week {
        color: rgba(0, 0, 0, 0.87) !important;
        -webkit-text-fill-color: rgba(0, 0, 0, 0.87) !important;
    }
}

.swm-datagrid .mud-icon-button {
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 15 !important;
}

.swm-datagrid .mud-icon-button .mud-icon-root {
    font-size: 1.15rem !important;
}

.swm-sticky-salon-col {
    position: sticky !important;
    right: 0 !important;
    z-index: 11 !important;
    min-width: 0 !important;
    background-color: var(--mud-palette-surface, #fff) !important;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.08);
}

.swmm-page .swm-sticky-salon-col {
    width: 1% !important;
    white-space: nowrap !important;
}

.swm-sticky-salon-col--with-select {
    right: 60px !important;
}

[data-theme="dark"] .swm-sticky-salon-col,
.mud-theme-dark .swm-sticky-salon-col {
    background-color: var(--mud-palette-surface, #1e1e1e) !important;
}

.swm-action-btn {
    min-height: 40px;
}

@media (max-width: 600px) {
    .swm-kpi-value {
        font-size: 1rem;
    }

    .swm-grid-wrap {
        height: min(62dvh, calc(100dvh - 340px));
    }
}

/* چاپ موجودی: فوتر پررنگ */
@media print {
    html body.print-report .swm-inventory-page .swm-datagrid-colored .mud-data-grid-footer td.swm-col-salon,
    html body.print-report .swm-inventory-page .swm-datagrid-colored .mud-data-grid-footer td.swm-col-salon *,
    html body.print-report .swm-inventory-page .swm-footer-salon {
        background-color: #263238 !important;
        background: #263238 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html body.print-report .swm-inventory-page .swm-datagrid-colored.swm-sex-female .mud-data-grid-footer td.swm-col-week,
    html body.print-report .swm-inventory-page .swm-datagrid-colored.swm-sex-female .mud-data-grid-footer td.swm-col-week *,
    html body.print-report .swm-inventory-page .swm-datagrid-colored.swm-sex-female .mud-data-grid-footer .swm-footer-num,
    html body.print-report .swm-inventory-page .swm-datagrid-colored.swm-sex-female .mud-data-grid-footer .swm-footer-week {
        background-color: #004d40 !important;
        background: #004d40 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html body.print-report .swm-inventory-page .swm-datagrid-colored.swm-sex-male .mud-data-grid-footer td.swm-col-week,
    html body.print-report .swm-inventory-page .swm-datagrid-colored.swm-sex-male .mud-data-grid-footer td.swm-col-week *,
    html body.print-report .swm-inventory-page .swm-datagrid-colored.swm-sex-male .mud-data-grid-footer .swm-footer-num,
    html body.print-report .swm-inventory-page .swm-datagrid-colored.swm-sex-male .mud-data-grid-footer .swm-footer-week {
        background-color: #0d47a1 !important;
        background: #0d47a1 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
