/* ── خط Cairo (متغيّر الوزن 200-1000) — مستضاف محلياً ── */
@font-face {
    font-family: 'Cairo';
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url('fonts/cairo-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

@font-face {
    font-family: 'Cairo';
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url('fonts/cairo-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Cairo';
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url('fonts/cairo-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

html, body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    height: 100%;
}

/* شريط تمرير أنيق */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.22);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

/* ترويسات جداول أوضح */
.mud-table-head .mud-table-cell {
    font-weight: 700;
}

/* البحث السريع في الشريط العلوي — حقل فاتح فوق خلفية الشريط الداكنة */
.appbar-search {
    max-width: 280px;
    margin-inline-start: 16px;
}

.appbar-search .mud-input-control,
.appbar-search .mud-input {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #fff !important;
}

.appbar-search .mud-input > input::placeholder {
    color: rgba(255, 255, 255, 0.75);
}

.appbar-search .mud-input-adornment .mud-icon-root,
.appbar-search .mud-input > input {
    color: #fff !important;
}

.appbar-search .mud-input.mud-input-outlined .mud-input-outlined-border {
    border-color: rgba(255, 255, 255, 0.35);
}

/* تذييل الصفحة */
.erp-footer {
    text-align: center;
    padding: 12px 16px 20px;
    opacity: .85;
}

/* بطاقات KPI في الرئيسية */
.kpi-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 12px;
}

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-value {
    font-weight: 800;
    font-size: 1.5rem;
    line-height: 1.1;
}

/* القائمة الجانبية: المحتوى يبدأ من الأعلى.
   السبب الجذري: .mud-divider-fullwidth فيه flex-grow:1 فيتمدّد عمودياً داخل عمود الـ Drawer
   ويدفع القائمة للأسفل. نمنع تمدّده. */
.erp-drawer .mud-drawer-content {
    justify-content: flex-start;
}

.erp-drawer .mud-divider {
    flex-grow: 0 !important;
}

.erp-drawer .mud-navmenu {
    flex: 0 0 auto;
}

/* حوارات وبطاقات بحواف أنعم */
.mud-dialog, .mud-paper {
    border-radius: 10px;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    left: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "حدث خطأ.";
}

/* ── التقارير المالية (Accounting statements) ── */
.erp-stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.erp-stat-tile {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 20px; min-width: 220px; flex: 1;
    border-radius: 10px;
}
.erp-stat-label { font-size: 0.85rem; color: var(--mud-palette-text-secondary); margin-bottom: 2px; }
.erp-stat-value { font-size: 1.5rem; font-weight: 700; color: var(--mud-palette-text-primary); line-height: 1.1; }

.erp-fin-section { display: flex; align-items: center; font-weight: 700; font-size: 1.05rem; margin: 8px 0 6px; }
.erp-fin-lines { width: 100%; border-collapse: collapse; }
.erp-fin-lines td { padding: 7px 8px; border-bottom: 1px solid var(--mud-palette-divider); }
.erp-fin-lines tr:last-child td { border-bottom: none; }

.erp-fin-total {
    display: grid; grid-template-columns: 1fr 170px 170px; align-items: center;
    padding: 12px 16px; margin-top: 4px; font-weight: 700; font-size: 1.05rem;
    border-top: 2px solid var(--mud-palette-lines-default); text-align: center;
}
.erp-fin-total > span:first-child { text-align: start; }
.erp-fin-total.ok { color: var(--mud-palette-success); }
.erp-fin-total.bad { color: var(--mud-palette-warning); }

.erp-fin-net {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; margin-top: 10px; border-radius: 8px;
    font-weight: 700; font-size: 1.15rem;
}
.erp-fin-net.profit { background: rgba(76,175,80,0.12); color: var(--mud-palette-success); }
.erp-fin-net.loss   { background: rgba(244,67,54,0.12); color: var(--mud-palette-error); }
.erp-fin-net.neutral { background: var(--mud-palette-background-grey); color: var(--mud-palette-text-primary); }

/* طباعة: التقرير فقط */
@media print {
    body * { visibility: hidden; }
    #report-print, #report-print * { visibility: visible; }
    #report-print { position: absolute; inset: 0; padding: 12px; }
    .erp-stat-tile { border: 1px solid #ddd; }
}

/* ── لمسات Vuexy (ظل بطاقات ناعم + رأس جدول مُظلَّل) ── */
.mud-elevation-1, .mud-elevation-2 {
    box-shadow: 0 2px 8px 0 rgba(47,43,61,0.12) !important;
}
.mud-table-root .mud-table-head .mud-table-cell {
    background-color: #F1F0F2;
    font-weight: 700;
    color: #4B465C;
}
:root[data-theme="dark"] .mud-elevation-1,
:root[data-theme="dark"] .mud-elevation-2 {
    box-shadow: 0 2px 8px 0 rgba(15,20,34,0.45) !important;
}
:root[data-theme="dark"] .mud-table-root .mud-table-head .mud-table-cell {
    background-color: #3A3F57;
    color: #CFCDE0;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .mud-table-root .mud-table-head .mud-table-cell {
        background-color: #3A3F57; color: #CFCDE0;
    }
}

/* ── أفاتار «tonal» بنمط Vuexy لبطاقات الإحصاء ── */
.erp-stat-avatar {
    width: 42px; height: 42px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.erp-stat-avatar .mud-icon-root { font-size: 1.6rem; }

/* ── صف حركة في widget آخر الحركات (نمط Vuexy RecentTransactions) ── */
.erp-activity-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 4px; border-bottom: 1px solid var(--mud-palette-divider);
}
.erp-activity-row:last-child { border-bottom: none; }

/* ── ترقيم بنمط Vuexy (معلومة يسار + أزرار مرقّمة) ── */
.erp-pager {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px 16px; flex-wrap: wrap;
}
.erp-pager-info { color: var(--mud-palette-text-secondary); font-size: 0.875rem; }
.erp-pager .mud-pagination-item .mud-button-root { border-radius: 6px; }
