﻿/* ══════════════════════════════════════════════
   BREAKPOINT MAP
   xs  : 0   – 479px   → small phones
   sm  : 480 – 639px   → large phones
   md  : 640 – 767px   → small tablets
   lg  : 768 – 1023px  → tablets
   xl  : 1024– 1279px  → small desktops
   2xl : 1280px+       → wide desktops
══════════════════════════════════════════════ */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background: #eef2f0;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    overflow-x: hidden;
    max-width: 100vw;
}

/* ── PAGE WRAPPER ── */
.pw {
    padding: 8px 6px 40px; /* 360px: padding أصغر لتوفير المساحة */
    max-width: 1400px;
    margin: 0 auto;
}

@media (min-width:400px) {
    .pw {
        padding: 10px 10px 40px;
    }
}

@media (min-width:480px) {
    .pw {
        padding: 14px 14px 44px;
    }
}

@media (min-width:768px) {
    .pw {
        padding: 20px 20px 52px;
    }
}

@media (min-width:1024px) {
    .pw {
        padding: 24px 28px 60px;
    }
}

/* ── CARD ── */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 14px rgba(0,0,0,.07);
    padding: 10px 8px; /* 360px: padding أصغر */
    margin-bottom: 10px;
    width: 100%;
    overflow: hidden;
}

@media (min-width:400px) {
    .card {
        padding: 12px 10px;
        border-radius: 11px;
        margin-bottom: 12px;
    }
}

@media (min-width:480px) {
    .card {
        padding: 16px;
        border-radius: 13px;
        margin-bottom: 16px;
    }
}

@media (min-width:768px) {
    .card {
        padding: 20px 22px;
        border-radius: 14px;
        margin-bottom: 20px;
    }
}

@media (min-width:1024px) {
    .card {
        padding: 22px 26px;
    }
}

/* ── PAGE HEADER ── */
.ph {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

@media (min-width:768px) {
    .ph {
        margin-bottom: 20px;
    }
}

.ph h4 {
    margin: 0;
    font-weight: 900;
    font-size: .9rem;
    color: #198754;
}

@media (min-width:480px) {
    .ph h4 {
        font-size: 1rem;
    }
}

@media (min-width:768px) {
    .ph h4 {
        font-size: 1.15rem;
    }
}

@media (min-width:1024px) {
    .ph h4 {
        font-size: 1.25rem;
    }
}

.ph .badge {
    background: #e6f4ec;
    color: #198754;
    border: 1px solid #b2dfcc;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

@media (min-width:768px) {
    .ph .badge {
        padding: 5px 16px;
        font-size: .8rem;
    }
}

/* ── FILTER GRID ── */
.fg {
    display: grid;
    grid-template-columns: 1fr; /* 360px: عمود واحد مريح */
    gap: 8px;
}

@media (min-width:400px) {
    .fg {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width:640px) {
    .fg {
        grid-template-columns: repeat(3,1fr);
        gap: 10px;
    }
}

@media (min-width:768px) {
    .fg {
        grid-template-columns: repeat(4,1fr);
        gap: 12px;
    }
}

@media (min-width:1024px) {
    .fg {
        grid-template-columns: repeat(5,1fr);
    }
}

@media (min-width:1280px) {
    .fg {
        grid-template-columns: repeat(6,1fr);
    }
}

.fg .span-full {
    grid-column: 1 / -1;
}

.fg label {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    color: #6c757d;
    margin-bottom: 3px;
}

@media (min-width:768px) {
    .fg label {
        font-size: .76rem;
    }
}

.fg select, .fg input {
    width: 100%;
    border: 1.5px solid #ced4da;
    border-radius: 8px;
    padding: 6px 8px;
    font-family: 'Cairo', sans-serif;
    font-size: .78rem;
    color: #212529;
    background: #fff;
    outline: none;
    transition: border-color .2s;
    max-width: 100%;
}

@media (min-width:768px) {
    .fg select, .fg input {
        padding: 7px 10px;
        font-size: .84rem;
    }
}

.fg select:focus, .fg input:focus {
    border-color: #198754;
    box-shadow: 0 0 0 3px rgba(25,135,84,.12);
}

.btn-search {
    width: 100%;
    padding: 9px;
    background: #198754;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background .2s;
}

    .btn-search:hover {
        background: #146c43;
    }

/* ── STAT CARDS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* دائماً 3 أعمدة حتى في 360px */
    gap: 6px;
    margin-bottom: 12px;
}

@media (min-width:480px) {
    .stats-grid {
        gap: 10px;
        margin-bottom: 14px;
    }
}

@media (min-width:768px) {
    .stats-grid {
        gap: 16px;
        margin-bottom: 20px;
    }
}

@media (min-width:1024px) {
    .stats-grid {
        gap: 20px;
    }
}

.sc {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
    padding: 10px 8px;
    display: flex;
    flex-direction: column; /* xs: أيقونة فوق + نص تحت */
    align-items: center;
    gap: 6px;
    text-align: center;
}

@media (min-width:480px) {
    .sc {
        flex-direction: row; /* sm+: أيقونة جنب النص */
        align-items: center;
        text-align: right;
        padding: 12px 14px;
        gap: 10px;
        border-radius: 12px;
    }
}

@media (min-width:768px) {
    .sc {
        padding: 18px 20px;
        gap: 16px;
        border-radius: 14px;
    }
}

@media (min-width:1024px) {
    .sc {
        padding: 20px 24px;
    }
}

.sc-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

@media (min-width:480px) {
    .sc-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
        border-radius: 11px;
    }
}

@media (min-width:768px) {
    .sc-icon {
        width: 52px;
        height: 52px;
        font-size: 22px;
        border-radius: 13px;
    }
}

@media (min-width:1024px) {
    .sc-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}

.sc-icon.g {
    background: #e8f5e9;
    color: #2e7d32;
}

.sc-icon.p {
    background: #fff8e1;
    color: #e65100;
}

.sc-icon.f {
    background: #e3f2fd;
    color: #1565c0;
}

.sc-body {
    min-width: 0;
}

    .sc-body .lbl {
        font-size: .6rem;
        color: #6c757d;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

@media (min-width:480px) {
    .sc-body .lbl {
        font-size: .7rem;
        white-space: normal;
    }
}

@media (min-width:768px) {
    .sc-body .lbl {
        font-size: .8rem;
    }
}

.sc-body .val {
    font-size: .95rem;
    font-weight: 900;
    line-height: 1.1;
}

@media (min-width:480px) {
    .sc-body .val {
        font-size: 1.4rem;
    }
}

@media (min-width:768px) {
    .sc-body .val {
        font-size: 1.8rem;
    }
}

@media (min-width:1024px) {
    .sc-body .val {
        font-size: 2rem;
    }
}

.sc-body .unit {
    font-size: .6rem;
    color: #6c757d;
}

@media (min-width:480px) {
    .sc-body .unit {
        font-size: .68rem;
    }
}

@media (min-width:768px) {
    .sc-body .unit {
        font-size: .75rem;
    }
}

/* ── SECTION HEADING ── */
.sh {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

    .sh h6 {
        margin: 0;
        font-size: .86rem;
        font-weight: 800;
        color: #198754;
    }

@media (min-width:768px) {
    .sh h6 {
        font-size: .95rem;
    }
}

.sh .tag {
    font-size: .7rem;
    color: #6c757d;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 3px 10px;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════
   VISIBILITY HELPERS
   xs/sm  : <640px   → mobile-only
   md/lg  : 640–1023 → tablet-only
   xl/2xl : 1024px+  → desktop-only
══════════════════════════════════════════════ */
.mobile-only {
    display: block;
}

.tablet-only {
    display: none;
}

.desktop-only {
    display: none;
}

@media (min-width:640px) and (max-width:1023px) {
    .mobile-only {
        display: none;
    }

    .tablet-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }
}

@media (min-width:1024px) {
    .mobile-only {
        display: none;
    }

    .tablet-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }
}

/* ══════════════════════════════════════════════
   MOBILE ITEM CARDS  (<640px)
══════════════════════════════════════════════ */
.item-card-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.item-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8faf9;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 9px 10px;
}

    .item-card .ic-num {
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: #198754;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: .68rem;
        font-weight: 900;
        flex-shrink: 0;
    }

    .item-card .ic-name {
        flex: 1;
        font-weight: 600;
        font-size: .8rem;
        text-align: right;
        /* منع الفيض */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .item-card .ic-count {
        background: #198754;
        color: #fff;
        border-radius: 18px;
        padding: 2px 9px;
        font-size: .74rem;
        font-weight: 700;
        white-space: nowrap;
        flex-shrink: 0;
    }

/* ══════════════════════════════════════════════
   TABLET ITEM CARDS  (640–1023px)
══════════════════════════════════════════════ */
.tablet-item-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (min-width:900px) {
    .tablet-item-grid {
        grid-template-columns: repeat(3,1fr);
    }
}

.tablet-item-card {
    background: #f8faf9;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

    .tablet-item-card .tic-num {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: #198754;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: .8rem;
        font-weight: 900;
        flex-shrink: 0;
    }

    .tablet-item-card .tic-name {
        flex: 1;
        font-weight: 700;
        font-size: .88rem;
        text-align: right;
    }

    .tablet-item-card .tic-count {
        background: #e6f4ec;
        color: #198754;
        border: 1px solid #b2dfcc;
        border-radius: 18px;
        padding: 4px 12px;
        font-size: .84rem;
        font-weight: 800;
        white-space: nowrap;
    }

/* ══════════════════════════════════════════════
   TABLE WRAPPER (desktop)
══════════════════════════════════════════════ */
.tw {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

    .tw table {
        width: max-content;
        min-width: 100%;
        margin: 0;
        border-collapse: collapse;
    }

    .tw th, .tw td {
        padding: 8px 10px !important;
        text-align: center;
        vertical-align: middle;
        white-space: nowrap;
        border: 1px solid #dee2e6;
        font-size: 12px;
    }

@media (min-width:768px) {
    .tw th, .tw td {
        font-size: 13px;
        padding: 10px 12px !important;
    }
}

@media (min-width:1024px) {
    .tw th, .tw td {
        font-size: 13.5px;
        padding: 10px 14px !important;
    }
}

.tw thead th {
    background: #d1e7dd;
    font-weight: 700;
}

.tw tfoot td {
    background: #fff3cd;
    font-weight: 700;
}

.tw tbody tr:nth-child(even) td {
    background: #f8faf9;
}

.tw .t-start {
    text-align: right !important;
}

/* Sticky branch column */
.branch-col {
    text-align: right !important;
    font-weight: 700;
    position: sticky;
    right: 0;
    z-index: 3;
    min-width: 90px;
    max-width: 150px;
    white-space: normal !important;
    word-break: break-word;
    border-right: 2px solid #adb5bd !important;
}

.tw thead th.branch-col {
    background: #d1e7dd;
    z-index: 4;
}

.tw tfoot td.branch-col {
    background: #fff3cd;
    z-index: 4;
}

.tw tbody td.branch-col {
    background: #fff;
}

.tw tbody tr:nth-child(even) td.branch-col {
    background: #f8faf9;
}

.num {
    font-weight: 700;
}

.muted0 {
    color: #ccc;
}

/* ══════════════════════════════════════════════
   MOBILE PIVOT CARDS  (<640px)
══════════════════════════════════════════════ */
.pivot-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pivot-card {
    background: #f8faf9;
    border: 1px solid #dee2e6;
    border-radius: 13px;
    overflow: hidden;
}

.pivot-card-head {
    background: #d1e7dd;
    padding: 9px 12px;
    font-weight: 800;
    font-size: .83rem;
    color: #155724;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .pivot-card-head i {
        color: #198754;
    }

.pivot-card-body {
    padding: 6px 12px;
}

.pivot-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #e9ecef;
    gap: 6px;
}

    .pivot-row:last-child {
        border-bottom: none;
    }

    .pivot-row .pr-label {
        font-size: .74rem;
        color: #495057;
        font-weight: 600;
        flex: 1;
        text-align: right;
        /* منع الكلمات الطويلة من كسر التصميم */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 180px;
    }

    .pivot-row .pr-val {
        font-size: .76rem;
        font-weight: 700;
        background: #e6f4ec;
        color: #198754;
        border-radius: 14px;
        padding: 2px 8px;
        min-width: 30px;
        text-align: center;
        white-space: nowrap;
        flex-shrink: 0;
    }

        .pivot-row .pr-val.zero {
            background: #f1f3f5;
            color: #adb5bd;
            font-weight: 400;
        }

.pivot-card.total-card {
    border-color: #ffc107;
}

    .pivot-card.total-card .pivot-card-head {
        background: #fff3cd;
        color: #7d5a00;
    }

    .pivot-card.total-card .pr-val {
        background: #fff3cd;
        color: #856404;
    }

/* ══════════════════════════════════════════════
   TABLET PIVOT CARDS  (640–1023px)
══════════════════════════════════════════════ */
.tablet-pivot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (min-width:900px) {
    .tablet-pivot-grid {
        grid-template-columns: repeat(3,1fr);
    }
}

.tablet-pivot-grid .span-full-tablet {
    grid-column: 1 / -1;
}

.tablet-pivot-card {
    background: #f8faf9;
    border: 1px solid #dee2e6;
    border-radius: 13px;
    overflow: hidden;
}

    .tablet-pivot-card .tpc-head {
        background: #d1e7dd;
        padding: 11px 16px;
        font-weight: 800;
        font-size: .9rem;
        color: #155724;
        display: flex;
        align-items: center;
        gap: 8px;
        border-bottom: 1px solid #c3dfc8;
    }

    .tablet-pivot-card .tpc-body {
        padding: 10px 16px;
    }

.tablet-pivot-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid #e9ecef;
    gap: 8px;
}

    .tablet-pivot-row:last-child {
        border-bottom: none;
    }

    .tablet-pivot-row .tpr-lbl {
        font-size: .8rem;
        color: #495057;
        font-weight: 600;
        flex: 1;
        text-align: right;
    }

    .tablet-pivot-row .tpr-val {
        font-size: .84rem;
        font-weight: 800;
        background: #e6f4ec;
        color: #198754;
        border-radius: 14px;
        padding: 3px 12px;
        min-width: 38px;
        text-align: center;
        white-space: nowrap;
    }

        .tablet-pivot-row .tpr-val.zero {
            background: #f1f3f5;
            color: #adb5bd;
            font-weight: 400;
        }

.tablet-pivot-card.total-card {
    border-color: #ffc107;
}

    .tablet-pivot-card.total-card .tpc-head {
        background: #fff3cd;
        color: #7d5a00;
        border-bottom-color: #f0d878;
    }

    .tablet-pivot-card.total-card .tpr-val {
        background: #fff3cd;
        color: #856404;
    }

.total-inner-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px,1fr));
    gap: 0;
}

    .total-inner-grid .tablet-pivot-row {
        border-bottom: 1px solid #f0d878;
    }

/* ── SCROLL HINT ── */
.hint {
    text-align: center;
    font-size: 11px;
    color: #adb5bd;
    margin-top: 5px;
    display: none;
}

@media (max-width:1023px) {
    .hint {
        display: block;
    }
}

/* ══════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: #adb5bd;
}

    .empty-state i {
        font-size: 2.5rem;
        margin-bottom: 10px;
        display: block;
    }

    .empty-state p {
        font-size: .88rem;
        margin: 0;
    }
