/* ════════════════════════════════════════════════════════
   responsive.css — Full Mobile/Tablet Responsive Fixes
   Najeeda ERP — Tested: 320px · 375px · 390px · 414px · 768px
   ════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════
   GLOBAL OVERFLOW PROTECTION
   ══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

@media (max-width: 768px) {
    /* Kill all horizontal scroll sources */
    .content-area,
    .tab-pane,
    .app-shell,
    .main-content { overflow-x: hidden; max-width: 100%; }

    /* All inputs/selects/textareas: 16px prevents iOS zoom */
    input, select, textarea,
    .fg input, .fg select, .fg textarea,
    .search-bar input, .search-bar select,
    .cust-search-input { font-size: 16px !important; }

    /* Prevent any fixed-width from overflowing */
    img, video, iframe, svg { max-width: 100%; height: auto; }
}

/* ══════════════════════════════════════════
   REPORTS — KPI CARDS
   ══════════════════════════════════════════ */
.rpt-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.rpt-kpi-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px 14px 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    position: relative;
    overflow: hidden;
    display: flex; flex-direction: column; gap: 4px;
}
.rpt-kpi-card::after {
    content: ''; position: absolute; top: 0; right: 0;
    width: 4px; height: 100%;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.rpt-kpi-card.blue::after   { background: var(--primary); }
.rpt-kpi-card.green::after  { background: var(--success); }
.rpt-kpi-card.red::after    { background: var(--danger); }
.rpt-kpi-card.gold::after   { background: var(--accent); }
.rpt-kpi-card.purple::after { background: var(--purple); }

.rkc-icon { font-size: 1.7rem; margin-bottom: 4px; }
.rkc-val  {
    font-size: 1.35rem; font-weight: 900; color: var(--primary);
    line-height: 1.15; word-break: break-word; overflow-wrap: anywhere;
}
.rkc-val.green  { color: var(--success); }
.rkc-val.red    { color: var(--danger); }
.rkc-val.gold   { color: var(--accent-dark); }
.rkc-curr { font-size: 0.62rem; color: var(--gray-400); font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; margin-top: -2px; }
.rkc-lbl  { font-size: 0.76rem; color: var(--gray-500); font-weight: 500; margin-top: 2px; }

.rpt-section-title {
    font-size: 0.88rem; font-weight: 700; color: var(--primary);
    margin: 16px 0 10px; padding-bottom: 6px;
    border-bottom: 2px solid var(--gray-200);
    display: flex; align-items: center; gap: 6px;
}
.rpt-two-col    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.rpt-export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.rpt-export-box { display: flex; flex-direction: column; gap: 0; }
.rpt-export-title { font-size: 0.9rem; font-weight: 700; color: var(--primary); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--gray-200); }
.rpt-export-fields { display: flex; flex-direction: column; gap: 10px; }
.rpt-export-note { font-size: 0.76rem; color: var(--gray-400); }
.erc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

@media (max-width: 1024px) {
    .rpt-kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .erc-grid     { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .rpt-kpi-grid    { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .rpt-two-col     { grid-template-columns: 1fr; }
    .rpt-export-grid { grid-template-columns: 1fr; }
    .erc-grid        { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 640px) {
    .rkc-val  { font-size: 1.1rem; }
    .rkc-icon { font-size: 1.4rem; }
    .rpt-kpi-card { padding: 12px 12px 10px; }
}
@media (max-width: 480px) {
    .rpt-kpi-grid { gap: 8px; }
    .rkc-val { font-size: 1rem; }
}

/* ══════════════════════════════════════════
   EXPENSE CUSTOM INPUT
   ══════════════════════════════════════════ */
.exp-custom-wrap {
    background: #fffbeb; border: 2px dashed var(--accent);
    border-radius: var(--radius-sm); padding: 12px 14px;
    animation: fadeIn .2s ease;
}
.exp-custom-label { color: var(--accent-dark) !important; font-size: 0.82rem !important; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.exp-custom-row { display: flex; gap: 8px; margin-top: 6px; }
.exp-custom-row input {
    flex: 1; padding: 10px 14px; border: 2px solid var(--accent);
    border-radius: var(--radius-sm); font-size: 0.9rem; outline: none;
    background: white; font-family: 'Tajawal', sans-serif;
    direction: ltr; text-align: left; transition: border-color .2s;
    min-width: 0; /* prevent overflow in flex */
}
.exp-custom-row input:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(201,168,76,.12); }
@keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }

/* ══════════════════════════════════════════
   EXPENSE FILTER
   ══════════════════════════════════════════ */
.exp-filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.exp-filter-actions {
    display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px;
    padding: 14px; background: var(--gray-50); border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}
.exp-filter-actions .btn { flex: 1; min-width: 120px; justify-content: center; font-size: 0.85rem; font-weight: 700; }

@media (max-width: 768px) { .exp-filter-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) {
    .exp-filter-grid { grid-template-columns: 1fr; }
    .exp-filter-actions .btn { flex: 1 1 calc(50% - 5px); min-width: unset; }
}

/* ══════════════════════════════════════════
   MOBILE CARD VIEW FOR TABLES
   ══════════════════════════════════════════ */

/* Desktop: card-primary is hidden (extra mobile-only td) */
.mobile-cards-table td.card-primary  { display: none; }
.mobile-cards-table td.desktop-only-col { /* visible on desktop */ }

@media (max-width: 640px) {

    /* ── Step 1: Remove ALL scroll containers on mobile ── */
    .tbl-wrap,
    .tbl-wrap * {
        /* Kill overflow-x on every ancestor of the table */
    }
    .tbl-wrap {
        overflow-x: visible !important;
        overflow-y: visible !important;
        background: transparent !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* ── Step 2: Table itself becomes full-width block ── */
    .mobile-cards-table,
    .mobile-cards-table tbody {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset !important;
        overflow: visible !important;
    }

    /* Hide thead */
    .mobile-cards-table thead { display: none !important; }

    /* ── Step 3: Each <tr> becomes a card ── */
    .mobile-cards-table tbody tr {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        background: white;
        border-radius: 16px;
        border: 1px solid var(--gray-200);
        margin-bottom: 14px;
        box-shadow: 0 2px 10px rgba(0,0,0,.07);
        overflow: hidden !important;
    }
    .mobile-cards-table tbody tr:last-child { margin-bottom: 0; }

    /* ── Step 4: Each <td> → label + value row using CSS Grid ── */
    .mobile-cards-table td {
        display: grid !important;
        grid-template-columns: 78px 1fr !important;
        column-gap: 8px !important;
        align-items: center !important;
        padding: 9px 14px !important;
        border-bottom: 1px solid var(--gray-100) !important;
        min-height: 36px !important;
        font-size: 0.84rem !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }
    .mobile-cards-table td:last-child { border-bottom: none !important; }

    /* ── Step 5: Label pseudo-element (column 1) ── */
    .mobile-cards-table td::before {
        content: attr(data-label) !important;
        display: block !important;
        font-size: 0.63rem !important;
        font-weight: 700 !important;
        color: var(--gray-400) !important;
        text-transform: uppercase !important;
        letter-spacing: 0.6px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        grid-column: 1 !important;
        align-self: center !important;
    }

    /* ── Step 6: Value content (column 2) ── */
    .mobile-cards-table td > *,
    .mobile-cards-table td > strong,
    .mobile-cards-table td > span,
    .mobile-cards-table td > a {
        grid-column: 2 !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        text-align: right !important;
        justify-self: end !important;
        display: block !important;
    }
    /* Allow badges and spans that need to be inline */
    .mobile-cards-table td > span.badge,
    .mobile-cards-table td > .badge { display: inline-block !important; }

    /* ── Card Header (gradient) ── */
    .mobile-cards-table td.card-primary {
        display: block !important;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
        color: white !important;
        padding: 12px 14px 10px !important;
        border-bottom: none !important;
        min-height: unset !important;
        overflow: hidden !important;
        grid-template-columns: 1fr !important;
    }
    .mobile-cards-table td.card-primary::before { display: none !important; }
    .mobile-cards-table td.card-primary > * {
        grid-column: 1 !important;
        text-align: left !important;
        justify-self: start !important;
        color: white !important;
        white-space: normal !important;
        overflow: hidden !important;
        max-width: 100% !important;
        display: block !important;
    }
    .mobile-cards-table td.card-primary strong { color: white !important; font-size: 0.95rem; }
    .mobile-cards-table td.card-primary > span { display: flex !important; gap: 5px; flex-wrap: wrap; margin-top: 3px; }

    /* ── Desktop-only column: hidden ── */
    .mobile-cards-table td.desktop-only-col { display: none !important; }

    /* ── Actions row ── */
    .mobile-cards-table td.card-actions {
        display: flex !important;
        justify-content: flex-end !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 10px 14px !important;
        background: var(--gray-50) !important;
        min-height: auto !important;
        overflow: visible !important;
        border-bottom: none !important;
        grid-template-columns: unset !important;
    }
    .mobile-cards-table td.card-actions::before { display: none !important; }
    .mobile-cards-table td.card-actions > *,
    .mobile-cards-table td.card-actions .actions {
        grid-column: unset !important;
        text-align: unset !important;
        justify-self: unset !important;
        white-space: unset !important;
        overflow: visible !important;
        max-width: unset !important;
        display: flex !important;
    }
    .mobile-cards-table td.card-actions .actions { flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
    .mobile-cards-table td.card-actions .btn-icon { min-width: 38px !important; min-height: 38px !important; }

    /* ── Empty state ── */
    .mobile-cards-table .empty-row td {
        display: block !important;
        text-align: center !important;
        border: none !important;
        min-height: auto !important;
        padding: 40px 16px !important;
        background: white !important;
        border-radius: 14px !important;
        grid-template-columns: unset !important;
    }
    .mobile-cards-table .empty-row td::before { display: none !important; }

    /* ── Colour helpers ── */
    .mobile-cards-table td.text-danger  { color: var(--danger) !important;  font-weight: 700; }
    .mobile-cards-table td.text-success { color: var(--success) !important; font-weight: 700; }

    /* ── Profit badge inside td ── */
    .mobile-cards-table td .profit-badge,
    .mobile-cards-table td .badge {
        white-space: nowrap; display: inline-flex; align-items: center;
    }
}

/* ══════════════════════════════════════════
   MODAL — BOTTOM SHEET ON MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .overlay { padding: 0; align-items: flex-end; overflow: hidden; }
    .modal {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 94vh;
        max-width: 100% !important;
        width: 100% !important;
        animation: modalSlideUp 0.3s cubic-bezier(.34,1.12,.64,1);
    }
    .modal-md, .modal-lg, .modal-xl { max-width: 100% !important; width: 100% !important; }
    .modal-head {
        padding: 14px 16px;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }
    .modal-head h4 { font-size: 0.92rem; }
    .modal-body { padding: 14px 16px; overflow-x: hidden; }
    .modal-foot {
        padding: 12px 16px;
        flex-wrap: wrap; gap: 8px;
        padding-bottom: max(12px, calc(12px + env(safe-area-inset-bottom)));
    }
    .modal-foot .btn { flex: 1; min-width: 100px; justify-content: center; }
}
@keyframes modalSlideUp {
    from { transform: translateY(100%); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Tablet modals — don't go full-screen, just fit nicely */
@media (min-width: 641px) and (max-width: 768px) {
    .modal    { max-width: calc(100vw - 32px); }
    .modal-lg { max-width: calc(100vw - 32px); }
    .modal-xl { max-width: calc(100vw - 32px); }
    .modal-body { overflow-x: hidden; }
}

/* ══════════════════════════════════════════
   FORM GRID — SINGLE COLUMN ON MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr !important; }
    .form-grid [style*="grid-column"] { grid-column: 1 !important; }
    .fg { gap: 5px; }
    .fg label { font-size: 0.82rem; }
    .fg input, .fg select, .fg textarea { font-size: 16px !important; }
    /* Multi-col upload row in doc panel */
    .doc-upload-row { grid-template-columns: 1fr !important; }
    .doc-upload-actions { justify-content: flex-end; }
}

/* ══════════════════════════════════════════
   SEARCH BAR — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .search-bar { flex-direction: column; gap: 8px; width: 100%; }
    .search-bar input,
    .search-bar select { min-width: unset; width: 100%; flex: 1 1 100%; font-size: 16px !important; }
    .search-bar input[type="date"] { flex: 1 1 calc(50% - 4px); min-width: 130px; font-size: 16px !important; }
    /* Put date inputs side by side on mobile */
    .search-bar { flex-wrap: wrap; }
}
@media (max-width: 360px) {
    .search-bar input[type="date"] { flex: 1 1 100%; }
}

/* ══════════════════════════════════════════
   FILTER BUTTONS — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .filter-row { gap: 5px; flex-wrap: wrap; }
    .fbtn { font-size: 0.75rem; padding: 6px 10px; }
}

/* ══════════════════════════════════════════
   SECTION HEAD — MOBILE WRAP
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
    .section-head { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
    .section-head h3 { font-size: 0.88rem; }
    .section-body { padding: 12px; }
}

/* ══════════════════════════════════════════
   VIEW GRID (DETAIL MODAL ROWS) — MOBILE
   ══════════════════════════════════════════ */
.vg-row { display: flex; gap: 12px; align-items: baseline; border-bottom: 1px solid var(--gray-100); padding-bottom: 6px; }
.vg-label { font-weight: 700; font-size: 0.82rem; color: var(--primary); min-width: 150px; flex-shrink: 0; }

@media (max-width: 480px) {
    .vg-row   { flex-direction: column; gap: 2px; padding-bottom: 8px; }
    .vg-label { min-width: unset; font-size: 0.75rem; }
    .vg-val   { font-size: 0.84rem; word-break: break-word; }
}

/* ══════════════════════════════════════════
   CONFIRM DIALOG — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
    .confirm-card     { max-width: calc(100vw - 32px); border-radius: 18px; }
    .confirm-top      { padding: 24px 20px 14px; }
    .confirm-icon-ring { width: 64px; height: 64px; font-size: 2rem; }
    .confirm-title    { font-size: 1rem; }
    .confirm-msg      { font-size: 0.82rem; }
    .confirm-btns     { padding: 12px 16px 20px; gap: 8px; }
    .confirm-btns .btn { height: 42px; font-size: 0.88rem; }
}

/* ══════════════════════════════════════════
   REPORTS — MONTHLY CARDS
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .month-card-hd { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 16px; }
    .month-hd-right { width: 100%; justify-content: space-between; gap: 8px; }
    .month-rev { font-size: 0.92rem; }
    .month-name { font-size: 0.95rem; }
    .month-section-lbl { font-size: 0.66rem; }
    .month-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 12px 0; }
    .ms-cell { padding: 10px 8px; }
    .ms-val { font-size: 0.9rem; }
    .ms-lbl { font-size: 0.62rem; }
    .month-status-row { gap: 6px; }
    .ms-tag { font-size: 0.72rem; padding: 4px 10px; }
}

/* ══════════════════════════════════════════
   B2B COMPANY REPORT — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .b2b-company-head { flex-direction: column; gap: 12px; }
    .b2b-comp-totals  { flex-wrap: wrap; width: 100%; }
    .b2b-tot-item     { flex: 1; min-width: calc(50% - 8px); }
    .b2b-filter-bar   { flex-direction: column; gap: 8px; }
    .b2b-filter-bar input,
    .b2b-filter-bar select { width: 100%; font-size: 16px !important; }
    .stmt-summary     { gap: 8px; flex-wrap: wrap; }
    .stmt-stat        { padding: 10px 12px; min-width: 80px; flex: 1; }
}

/* ══════════════════════════════════════════
   USER CARDS — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 480px) {
    .user-card { flex-direction: column; text-align: center; padding: 14px 16px; }
    .user-info { text-align: center; }
    .user-info h4 { justify-content: center; }
    .user-actions { justify-content: center; flex-wrap: wrap; }
}

/* ══════════════════════════════════════════
   EMPLOYEE / SUPPLIER / COMPANY CARDS
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .pro-grid, .emp-grid, .comp-grid { grid-template-columns: 1fr !important; gap: 14px; }
    .emp-card-actions, .comp-card-actions { flex-wrap: wrap; gap: 6px; }
}
@media (min-width: 641px) and (max-width: 960px) {
    .pro-grid, .emp-grid, .comp-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ══════════════════════════════════════════
   EMPLOYEE REPORT CARDS — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .erc-head    { flex-direction: column; padding: 16px; gap: 10px; }
    .erc-name    { font-size: 1rem; flex-wrap: wrap; }
    .erc-orders  { grid-template-columns: repeat(2,1fr); }
    .erc-finance { grid-template-columns: repeat(2,1fr); }
    .erc-order-val { font-size: 1.2rem; }
    .erc-fin-val   { font-size: 0.82rem; }
    .erc-foot    { flex-direction: column; gap: 8px; align-items: flex-start; }
    .erc-status  { position: static; display: inline-block; margin-bottom: 6px; }
}
@media (max-width: 380px) {
    .erc-fin-val   { font-size: 0.74rem; }
    .erc-order-val { font-size: 1rem; }
}

/* ══════════════════════════════════════════
   REPORT STATS — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .report-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .rs .rv { font-size: 1.1rem; }
    .rs .rl { font-size: 0.68rem; }
    .report-card { padding: 16px; }
}

/* ══════════════════════════════════════════
   INVOICE & VOUCHER — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .inv-controls { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 14px; }
    .inv-ctrl-input { width: 100%; min-width: unset; }
    .inv-controls label { font-size: 0.82rem; }
    .vou-header { flex-direction: column; gap: 8px; }
    .vou-header .vd { text-align: left; }
    .vou-amount .va-v { font-size: 1.8rem; }
    .vou-wrap { padding: 16px 14px; }
}

/* Invoice filter row */
@media (max-width: 768px) {
    #invoiceFilterRow { flex-wrap: wrap; gap: 6px; }
    #invoiceFilterRow input, #invoiceFilterRow select { font-size: 16px !important; }
    #rvFilterRow input, #rvFilterRow select,
    #pvFilterRow input, #pvFilterRow select { font-size: 16px !important; }
}

/* ══════════════════════════════════════════
   SUPPLIER DETAIL TABLE — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    #supListContent .data-table th,
    #supListContent .data-table td { padding: 8px 10px; font-size: 0.8rem; }
}

/* ══════════════════════════════════════════
   DOCUMENT UPLOAD PANEL — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    .doc-upload-row { grid-template-columns: 1fr !important; }
    .doc-upload-actions { justify-content: flex-end; }
    .doc-card { gap: 8px; padding: 9px 10px; }
    .doc-name { font-size: 0.82rem; }
}

/* ══════════════════════════════════════════
   TOPBAR — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
    .hamburger-btn { min-width: 40px; min-height: 40px; }
    .mobile-page-title { font-size: 0.84rem; }
}

/* ══════════════════════════════════════════
   TOUCH TARGETS (pointer: coarse)
   ══════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
    .btn      { min-height: 40px; }
    .btn-sm   { min-height: 34px; }
    .btn-icon { min-width: 40px; min-height: 40px; }
    .fbtn     { min-height: 36px; padding: 8px 14px; }
    .sfb      { min-height: 38px; }
    .sidebar-item { padding: 10px 9px; min-height: 44px; }
    .role-tab { padding: 12px 10px; }
    /* No sticky hover on touch */
    .btn:hover        { transform: none !important; opacity: 1 !important; }
    .stat-card:hover  { transform: none !important; box-shadow: var(--shadow) !important; }
    .quick-card:hover { transform: none !important; }
    .pro-card:hover   { transform: none !important; box-shadow: 0 2px 8px rgba(0,0,0,.06) !important; }
    .erc:hover        { transform: none !important; }
}

/* ══════════════════════════════════════════
   SAFE AREA INSETS (iPhone notch)
   ══════════════════════════════════════════ */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .mobile-topbar { padding-top: max(0px, env(safe-area-inset-top)); }
        .modal-foot    { padding-bottom: max(12px, calc(12px + env(safe-area-inset-bottom))); }
        .sidebar       { padding-bottom: env(safe-area-inset-bottom); }
    }
}

/* ══════════════════════════════════════════
   STAT CARDS — EXTRA SMALL
   ══════════════════════════════════════════ */
@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-value { font-size: 1.3rem; }
    .stat-icon  { font-size: 1.6rem; margin-bottom: 6px; }
    .stat-label { font-size: 0.74rem; }
}

/* ══════════════════════════════════════════
   RTL MOBILE OVERRIDES
   ══════════════════════════════════════════ */
@media (max-width: 640px) {
    html[dir="rtl"] .modal-foot  { flex-direction: row-reverse; }
    html[dir="rtl"] .user-card   { flex-direction: column-reverse; }
    html[dir="rtl"] .user-info   { text-align: center; }
    html[dir="rtl"] .vg-row      { flex-direction: column; }
    /* RTL mobile card: flip label/value sides */
    html[dir="rtl"] .mobile-cards-table td::before { text-align: right !important; }
    html[dir="rtl"] .mobile-cards-table td > *     { text-align: left !important; justify-self: start !important; }
    html[dir="rtl"] .mobile-cards-table td.card-primary > * { text-align: right !important; justify-self: end !important; }
}

/* ══════════════════════════════════════════
   PRINT
   ══════════════════════════════════════════ */
@media print {
    .sidebar, .sidebar-pin, .sidebar-overlay, .mobile-topbar,
    .hamburger-btn, .section-head .btn, .actions, .modal-foot,
    .sfb, .sidebar-collapse-btn { display: none !important; }
    .main-content { margin-left: 0 !important; margin-right: 0 !important; }
    .content-area { padding: 0 !important; }
    .section, .section-card { box-shadow: none !important; border: 1px solid #ddd !important; overflow: hidden !important; }
}
