/* --- SCOPED CSS FOR AGEING REPORT --- */
.ar-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    font-family: 'Inter', sans-serif;
}

.ar-header-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .ar-header-text h1 {
        margin: 0;
        font-size: 24px;
        font-weight: 700;
        color: #334155;
    }

    .ar-header-text p {
        margin: 0;
        font-size: 14px;
        color: #475569;
    }

.ar-action-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.ar-btn-outline {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    color: #64748b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

    .ar-btn-outline:hover {
        background-color: #f8fafc;
        border-color: #94a3b8;
        color: #334155;
    }

.ar-btn-solid {
    background-color: #3b82f6;
    border: 1px solid #3b82f6;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

    .ar-btn-solid:hover {
        background-color: #2563eb;
    }

/* --- Statistics Grid --- */
.ar-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    font-family: 'Inter', sans-serif;
    margin-bottom: 24px;
}

.ar-stat-card {
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid #f1f5f9;
    border-left-width: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.ar-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.ar-stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ar-stat-title {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
}

.ar-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
}

.ar-stat-trend {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #16a34a;
}

.ar-trend-icon {
    color: #3b82f6;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.ar-icon-box {
    width: 38px;
    height: 38px;
    background-color: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    flex-shrink: 0;
}

    .ar-icon-box svg {
        width: 16px;
        height: 16px;
    }

.ar-theme-green {
    border-left-color: #16a34a;
    background: linear-gradient(90deg, #ecfdf5 0%, #ffffff 80%);
}

    .ar-theme-green .ar-icon-box {
        color: #16a34a;
    }

.ar-theme-orange {
    border-left-color: #b45309;
    background: linear-gradient(90deg, #fff7ed 0%, #ffffff 80%);
}

    .ar-theme-orange .ar-icon-box {
        color: #b45309;
    }

.ar-theme-yellow {
    border-left-color: #ca8a04;
    background: linear-gradient(90deg, #fefce8 0%, #ffffff 80%);
}

    .ar-theme-yellow .ar-icon-box {
        color: #ca8a04;
    }

.ar-theme-red {
    border-left-color: #dc2626;
    background: linear-gradient(90deg, #fef2f2 0%, #ffffff 80%);
}

    .ar-theme-red .ar-icon-box {
        color: #dc2626;
    }


/* --- Charts Section --- */
.ar-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    font-family: 'Inter', sans-serif;
    margin-bottom: 24px;
}

.ar-chart-card {
    background-color: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    padding: 20px 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    max-width: 100%;
    overflow: hidden;
}

.ar-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

    .ar-chart-header h3 {
        margin: 0;
        font-size: 15px;
        font-weight: 600;
        color: #334155;
    }

.ar-custom-legend {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.ar-leg-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.leg-stock {
    color: #16a34a;
}

.leg-sales {
    color: #3b82f6;
}

.ar-chart-area {
    position: relative;
    width: 100%;
    height: 260px;
}

.ar-donut-container {
    display: flex;
    align-items: center;
    gap: 32px;
    height: 260px;
}

.ar-donut-wrapper {
    width: 45%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ar-donut-table-wrapper {
    width: 55%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-x: auto;
}

.ar-data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 280px;
}

    .ar-data-table th {
        text-align: left;
        padding: 12px 8px;
        border-bottom: 1px solid #e2e8f0;
        color: #1e293b;
        font-weight: 600;
        font-size: 13px;
        white-space: nowrap;
    }

    .ar-data-table td {
        padding: 14px 8px;
        border-bottom: 1px solid #f1f5f9;
        color: #475569;
        font-size: 13px;
        font-weight: 500;
        vertical-align: middle;
        white-space: nowrap;
    }

    .ar-data-table tr:last-child td {
        border-bottom: none;
    }

.ar-dot-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ar-table-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot-dgreen {
    background-color: #047857;
}

.dot-lgreen {
    background-color: #65a30d;
}

.dot-orange {
    background-color: #ea580c;
}

.dot-red {
    background-color: #ef4444;
}


/* --- Filters Section --- */
.ar-filter-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 24px;
    font-family: 'Inter', sans-serif;
}

.ar-filter-header {
    background-color: #f1f5f9;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
}

.ar-filter-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.ar-filter-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Collapsible filter card (desktop / tablet): the header toggles the body. */
.ar-filter-header {
    cursor: pointer;
}

.ar-filter-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.ar-filter-card--collapsed .ar-filter-chevron {
    transform: rotate(-90deg);
}

.ar-filter-card--collapsed .ar-filter-header {
    border-bottom: 0;
}

.ar-filter-card--collapsed .ar-filter-body {
    display: none;
}

/* Active-filter count shown next to "Filters" while the card is collapsed. */
.ar-filter-card .ar-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 6px;
    border-radius: 999px;
    background: #3b82f6;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
}

.ar-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px 20px;
}

.ar-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ar-form-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.ar-form-input, .ar-form-select {
    appearance: none;
    background-color: #fafafa;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: #94a3b8;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

    .ar-form-input:focus, .ar-form-select:focus {
        border-color: #3b82f6;
    }

.ar-form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.ar-filter-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

/* --- Table Section --- */
.ar-table-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    gap: 20px;
    font-family: 'Inter', sans-serif;
    margin-bottom: 20px;
    max-width: 100%;
    overflow: hidden;
}

.ar-table-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

    .ar-table-top h3 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: #334155;
    }

.ar-search-input {
    appearance: none;
    background-color: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    padding: 8px 16px 8px 36px;
    font-size: 13px;
    color: #334155;
    width: 260px;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    transition: border-color 0.2s;
    max-width: 100%;
}

    .ar-search-input:focus {
        border-color: #3b82f6;
    }

.ar-table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}

.ar-main-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

    .ar-main-table th {
        background-color: #f8fafc;
        color: #475569;
        font-weight: 600;
        font-size: 13px;
        padding: 14px 16px;
        text-align: center;
        white-space: nowrap;
        border-bottom: 1px solid #e2e8f0;
    }

    .ar-main-table td {
        padding: 16px;
        text-align: center;
        border-bottom: 1px solid #f1f5f9;
        font-size: 13px;
        color: #334155;
        vertical-align: middle;
    }

    .ar-main-table tr:last-child td {
        border-bottom: none;
    }

.ar-checkbox {
    width: 16px;
    height: 16px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    appearance: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .ar-checkbox:checked {
        background-color: #3b82f6;
        border-color: #3b82f6;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
        background-position: center;
        background-repeat: no-repeat;
    }

/* Table Text Colors */
.ar-txt-red {
    color: #ef4444;
    font-weight: 600;
}

.ar-txt-lgreen {
    color: #65a30d;
    font-weight: 600;
}

.ar-txt-dgreen {
    color: #16a34a;
    font-weight: 600;
}

.ar-txt-orange {
    color: #ea580c;
    font-weight: 600;
}

/* Table Status Badges */
.ar-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

    .ar-status .dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
    }

.ar-st-red {
    background: #fee2e2;
    color: #ef4444;
}

    .ar-st-red .dot {
        background: #ef4444;
    }

.ar-st-lgreen {
    background: #ecfccb;
    color: #65a30d;
}

    .ar-st-lgreen .dot {
        background: #65a30d;
    }

.ar-st-dgreen {
    background: #dcfce7;
    color: #16a34a;
}

    .ar-st-dgreen .dot {
        background: #16a34a;
    }

.ar-st-orange {
    background: #ffedd5;
    color: #ea580c;
}

    .ar-st-orange .dot {
        background: #ea580c;
    }

.ar-action-btn {
    background: none;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    transition: opacity 0.2s;
}

    .ar-action-btn:hover {
        opacity: 0.7;
    }

/* Pagination */
.ar-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding-top: 4px;
}

.ar-page-size {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #334155;
    font-weight: 500;
}

.ar-page-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ar-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    border-radius: 6px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
}

    .ar-page-btn:hover:not(.dots) {
        background-color: #f8fafc;
    }

    .ar-page-btn.active {
        background-color: #f1f5f9;
        border-color: #e2e8f0;
        font-weight: 600;
        color: #1e293b;
    }

    .ar-page-btn.dots {
        border: none;
        background: transparent;
        cursor: default;
    }

/* --- Responsive Queries --- */
@media (max-width: 1280px) {
    .ar-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .ar-charts-grid {
        grid-template-columns: 1fr;
    }

    .ar-filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .ar-header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .ar-table-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .ar-action-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

        .ar-action-buttons .ar-btn {
            justify-content: center;
            width: 100%;
        }

    .ar-stats-grid {
        grid-template-columns: 1fr;
    }

    .ar-donut-container {
        flex-direction: column;
        height: auto;
        gap: 20px;
    }

    .ar-donut-wrapper, .ar-donut-table-wrapper {
        width: 100%;
    }

    .ar-donut-wrapper {
        height: 260px;
    }
}

@media (max-width: 640px) {
    .ar-action-buttons {
        grid-template-columns: 1fr;
    }

    .ar-filter-grid {
        grid-template-columns: 1fr;
    }

    .ar-filter-actions {
        flex-direction: column;
        width: 100%;
    }

        .ar-filter-actions .ar-btn {
            width: 100%;
            justify-content: center;
        }

}

/* =========================================================
   AGEING REPORT: SELECT2 INITIALIZATION + LOADING BEHAVIOUR
   ========================================================= */

.ar-page-container,
.ar-page-container *,
.ar-page-container *::before,
.ar-page-container *::after {
    box-sizing: border-box;
}

.ar-btn:disabled,
.ar-page-btn:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

    .ar-btn:disabled:hover,
    .ar-page-btn:disabled:hover {
        transform: none;
    }

/* Hide the browser's expanded native multi-select until Select2 is attached. */
.ar-form-group {
    position: relative;
    min-width: 0;
}

select.ar-form-select[multiple]:not(.select2-hidden-accessible) {
    display: block !important;
    width: 100% !important;
    height: 38px !important;
    min-height: 38px !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: hidden !important;
    opacity: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}

/* Temporary closed-dropdown visual; removed automatically after Select2 attaches. */
.ar-form-group:has(> select.ar-form-select[multiple]:not(.select2-hidden-accessible))::after {
    content: "Select an option";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    height: 38px;
    display: flex;
    align-items: center;
    padding: 0 40px 0 12px;
    overflow: hidden;
    color: #94a3b8;
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
    background-color: #fafafa;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    pointer-events: none;
}

.ar-form-group:has(> select.ar-form-select[multiple]:not(.select2-hidden-accessible))::before {
    content: "";
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 3;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid #94a3b8;
    border-bottom: 1.5px solid #94a3b8;
    transform: rotate(45deg);
    pointer-events: none;
}

/* Select2 sizing and appearance scoped to Ageing Report. */
.ar-filter-body .select2-container {
    width: 100% !important;
    min-width: 0 !important;
}

.ar-page-container .select2-container--default .select2-selection--multiple {
    width: 100% !important;
    min-height: 38px !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    padding: 3px 42px 3px 6px !important;
    color: #334155 !important;
    background-color: #fafafa !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    border: 1px solid #f1f5f9 !important;
    border-radius: 8px !important;
    outline: none !important;
}

.ar-page-container .select2-container--default.select2-container--focus .select2-selection--multiple,
.ar-page-container .select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: #3b82f6 !important;
}

.ar-page-container .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 4px;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.ar-page-container .select2-search--inline {
    display: block !important;
    flex: 1 1 120px !important;
    min-width: 80px !important;
    margin: 0 !important;
    padding: 0 !important;
}

    .ar-page-container .select2-search--inline .select2-search__field {
        width: 100% !important;
        min-width: 80px !important;
        height: 28px !important;
        margin: 0 !important;
        padding: 0 4px !important;
        color: #334155 !important;
        font-family: inherit !important;
        font-size: 13px !important;
        line-height: 28px !important;
        background: transparent !important;
        border: 0 !important;
        outline: none !important;
    }

/* Selected chip and its individual right-aligned cancel button. */
.ar-page-container .select2-container--default .select2-selection--multiple .select2-selection__choice {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    max-width: calc(100% - 4px);
    min-height: 26px;
    margin: 1px 0 !important;
    padding: 3px 27px 3px 8px !important;
    overflow: hidden;
    color: #334155 !important;
    font-size: 12px !important;
    line-height: 18px !important;
    background-color: #e8eef7 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 5px !important;
}

.ar-page-container .select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    display: block;
    max-width: 100%;
    padding: 0 !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ar-page-container .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    position: absolute !important;
    top: 50% !important;
    right: 3px !important;
    left: auto !important;
    width: 20px !important;
    height: 20px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #64748b !important;
    font-size: 0 !important;
    line-height: 1 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 50% !important;
    transform: translateY(-50%);
    cursor: pointer !important;
    z-index: 2;
}

    .ar-page-container .select2-container--default .select2-selection--multiple .select2-selection__choice__remove::before {
        content: "\00D7";
        font-size: 16px;
        font-weight: 600;
        line-height: 1;
    }

    .ar-page-container .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
        color: #0f172a !important;
        background-color: #cbd5e1 !important;
    }

.ar-page-container .select2-container--default .select2-selection--multiple .select2-selection__clear {
    position: absolute !important;
    top: 50% !important;
    right: 32px !important;
    height: 20px !important;
    margin: 0 !important;
    color: #64748b !important;
    font-size: 16px !important;
    line-height: 20px !important;
    transform: translateY(-50%);
}

/* Initial skeleton and later background-refresh behaviour. */
.ar-dashboard-skeleton,
.ar-dashboard-content {
    position: relative;
    min-height: 500px;
}

.ar-loading-status {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 14px 2px;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
}

.ar-inline-spinner {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border: 2px solid #dbeafe;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: ar-spin 0.75s linear infinite;
}

.ar-refresh-indicator {
    position: sticky;
    top: 12px;
    z-index: 40;
    width: max-content;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px auto;
    padding: 7px 12px;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 700;
    background: rgba(239, 246, 255, 0.96);
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

.ar-dashboard-warning,
.ar-empty-state {
    padding: 14px 16px;
    color: #b45309;
    font-size: 13px;
    text-align: center;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
}

.ar-empty-state {
    margin-top: 8px;
    padding: 48px 20px;
    color: #64748b;
    background: #ffffff;
    border-color: #e2e8f0;
}

.ar-dashboard-warning {
    margin-bottom: 16px;
}

.ar-dashboard-content.is-refreshing > :not(.ar-refresh-indicator):not(.ar-dashboard-warning) {
    opacity: 0.62;
    filter: grayscale(12%);
    pointer-events: none;
    transition: opacity 0.2s ease, filter 0.2s ease;
}

/* Skeleton shimmer. */
.ar-skeleton-block {
    position: relative;
    display: block;
    overflow: hidden;
    background: #e8edf3;
    border-radius: 6px;
}

    .ar-skeleton-block::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.72) 48%, transparent 100%);
        transform: translateX(-100%);
        animation: ar-skeleton-shimmer 1.35s ease-in-out infinite;
    }

.ar-skeleton-stat-card {
    min-height: 116px;
    background: #ffffff;
    border-color: #e2e8f0;
}

.ar-skeleton-stat-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.ar-skeleton-stat-copy {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ar-skeleton-title {
    width: 58%;
    height: 12px;
}

.ar-skeleton-value {
    width: 34%;
    height: 22px;
}

.ar-skeleton-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
}

.ar-skeleton-trend {
    width: 48%;
    height: 11px;
    margin-top: 16px;
}

.ar-skeleton-chart-card,
.ar-skeleton-donut-card {
    min-height: 342px;
}

.ar-skeleton-heading {
    width: 180px;
    max-width: 60%;
    height: 17px;
    margin-bottom: 26px;
}

.ar-skeleton-bar-chart {
    height: 260px;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 20px;
    padding: 20px 24px 0 46px;
    border-left: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 51px, #f1f5f9 52px);
}

    .ar-skeleton-bar-chart .ar-skeleton-block {
        width: 42px;
        max-width: 11%;
        min-width: 18px;
        border-radius: 6px 6px 0 0;
    }

        .ar-skeleton-bar-chart .ar-skeleton-block:nth-child(1) {
            height: 38%;
        }

        .ar-skeleton-bar-chart .ar-skeleton-block:nth-child(2) {
            height: 62%;
        }

        .ar-skeleton-bar-chart .ar-skeleton-block:nth-child(3) {
            height: 48%;
        }

        .ar-skeleton-bar-chart .ar-skeleton-block:nth-child(4) {
            height: 79%;
        }

        .ar-skeleton-bar-chart .ar-skeleton-block:nth-child(5) {
            height: 57%;
        }

        .ar-skeleton-bar-chart .ar-skeleton-block:nth-child(6) {
            height: 70%;
        }

.ar-skeleton-donut-layout {
    min-height: 260px;
    display: grid;
    grid-template-columns: minmax(150px, 0.9fr) minmax(200px, 1.1fr);
    align-items: center;
    gap: 32px;
}

.ar-skeleton-donut {
    width: 190px;
    height: 190px;
    max-width: 100%;
    justify-self: center;
    border-radius: 50%;
}

    .ar-skeleton-donut::before {
        content: "";
        position: absolute;
        inset: 36px;
        z-index: 2;
        background: #ffffff;
        border-radius: 50%;
    }

.ar-skeleton-donut-rows {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

    .ar-skeleton-donut-rows .ar-skeleton-block {
        width: 100%;
        height: 15px;
    }

        .ar-skeleton-donut-rows .ar-skeleton-block:nth-child(2),
        .ar-skeleton-donut-rows .ar-skeleton-block:nth-child(4) {
            width: 84%;
        }

.ar-skeleton-table-card {
    overflow: hidden;
}

.ar-skeleton-table-title {
    width: 180px;
    height: 18px;
}

.ar-skeleton-search {
    width: 260px;
    max-width: 42%;
    height: 34px;
}

.ar-skeleton-table-scroll {
    width: 100%;
    overflow: hidden;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
}

.ar-skeleton-table-head,
.ar-skeleton-table-row {
    min-width: 1000px;
    display: grid;
    grid-template-columns: 55px repeat(7, minmax(95px, 1fr));
    gap: 16px;
    padding: 14px 16px;
}

.ar-skeleton-table-head {
    background: #f8fafc;
}

    .ar-skeleton-table-head .ar-skeleton-block,
    .ar-skeleton-table-row .ar-skeleton-block {
        height: 12px;
    }

.ar-skeleton-table-row {
    border-bottom: 1px solid #f1f5f9;
}

.ar-skeleton-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 4px;
}

    .ar-skeleton-pagination .ar-skeleton-block:first-child {
        width: 150px;
        height: 32px;
    }

    .ar-skeleton-pagination .ar-skeleton-block:last-child {
        width: 205px;
        height: 32px;
    }

@keyframes ar-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ar-skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

@media (max-width: 768px) {
    .ar-refresh-indicator {
        position: static;
        margin-left: auto;
    }

    .ar-skeleton-donut-layout {
        grid-template-columns: 1fr;
    }

    .ar-skeleton-donut {
        width: 170px;
        height: 170px;
    }

    .ar-skeleton-search {
        width: 100%;
        max-width: 100%;
    }

    .ar-skeleton-bar-chart {
        min-width: 650px;
    }

    .ar-skeleton-chart-card {
        overflow-x: auto;
    }
}


/* Production-safe ageing distinction: Long Aged is amber; Critical stays red. */
.ar-txt-amber {
    color: #b45309;
    font-weight: 600;
}

.ar-st-amber {
    background: #fef3c7;
    color: #b45309;
}

    .ar-st-amber .dot {
        background: #d97706;
    }

/* ========================================================
   PageHeader adoption: keep the desktop title row exactly as
   the old .ar-header-container looked (24px title, 14px subtitle).
   ======================================================== */
.ar-page-container .shell-page-header.ar-header-container {
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin: 0 0 24px;
    font-family: 'Inter', sans-serif;
}

    .ar-page-container .shell-page-header.ar-header-container .shell-page-title {
        margin: 0;
        font-size: 24px;
        font-weight: 700;
        line-height: 1.2;
        color: #334155;
    }

    .ar-page-container .shell-page-header.ar-header-container .shell-page-subtitle {
        margin: 4px 0 0;
        font-size: 14px;
        color: #475569;
    }

    .ar-page-container .shell-page-header.ar-header-container .shell-page-actions {
        gap: 10px;
        flex-wrap: wrap;
    }

/* "View" label next to the row action icon: phone only */
.ar-action-text {
    display: none;
}

.ar-empty-state .spic-empty {
    width: 100%;
}

/* native: phone */
@media (max-width: 767.98px) {
    .ar-page-container {
        padding-top: 12px !important;
        padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    }

    /* Header: title row, then the four actions as a 2 x 2 grid */
    .ar-page-container .shell-page-header.ar-header-container {
        gap: 8px;
        margin-bottom: 16px;
    }

        .ar-page-container .shell-page-header.ar-header-container .shell-page-title {
            font-size: 1.15rem;
        }

        .ar-page-container .shell-page-header.ar-header-container .shell-page-subtitle {
            font-size: 0.8rem;
            margin-top: 2px;
        }

        .ar-page-container .shell-page-header.ar-header-container .shell-page-actions {
            flex-basis: 100%;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }

    .ar-page-container .ar-btn {
        min-height: var(--tap-min, 44px);
        width: 100%;
        justify-content: center;
    }

    /* Filters trigger (opens the BottomSheet) */
    .ar-filter-trigger {
        width: 100%;
        min-height: var(--tap-min, 44px);
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        padding: 10px 16px;
        margin-bottom: 16px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        color: #1e293b;
        font-family: 'Inter', sans-serif;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        text-align: left;
    }

        .ar-filter-trigger:disabled {
            opacity: 0.6;
        }

    .ar-filter-count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 22px;
        height: 22px;
        padding: 0 7px;
        margin-left: 6px;
        border-radius: 999px;
        background: #3b82f6;
        color: #ffffff;
        font-size: 12px;
        font-weight: 600;
    }

    /* Filter fields inside the sheet: one column, native multi-selects visible */
    .ar-page-container .ar-filter-sheet .ar-filter-body {
        padding: 0;
        gap: 0;
    }

    .ar-page-container .ar-filter-sheet .ar-filter-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Select2 runs inside the sheet; each dropdown is attached to its field's form
       group (dropdownParent), which is its positioning context. The open field is
       lifted above the fields that follow so the list is not painted under them. */
    .ar-filter-sheet .ar-form-group {
        position: relative;
    }

    .ar-filter-sheet .ar-form-group:has(.select2-container--open) {
        z-index: 5;
    }

    .ar-filter-sheet .select2-container {
        width: 100% !important;
        min-width: 0 !important;
    }

    .ar-filter-sheet .select2-dropdown {
        font-size: 14px;
    }

    .ar-filter-sheet .select2-results__options {
        max-height: 220px;
    }

    /* Fallback only: a native multi-select that Select2 has not (yet) taken over. */
    .ar-page-container .ar-filter-sheet select.ar-form-select[multiple]:not(.select2-hidden-accessible) {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: var(--tap-min, 44px) !important;
        max-height: 168px;
        margin: 0 !important;
        padding: 6px 8px !important;
        visibility: visible !important;
        opacity: 1 !important;
        overflow: auto !important;
        pointer-events: auto !important;
        appearance: auto !important;
        -webkit-appearance: auto !important;
        background-image: none;
        color: #334155;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

        .ar-page-container .ar-filter-sheet select.ar-form-select[multiple] option {
            padding: 8px 6px;
        }

    .ar-page-container .ar-filter-sheet .ar-form-group::after,
    .ar-page-container .ar-filter-sheet .ar-form-group::before {
        content: none !important;
    }

    .ar-page-container .ar-filter-sheet .ar-btn {
        width: auto;
    }

    /* KPI tiles: two per row */
    .ar-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .ar-stat-card {
        padding: 14px;
    }

    .ar-stat-title {
        font-size: 12px;
    }

    .ar-stat-value {
        font-size: 18px;
    }

    .ar-stat-trend {
        font-size: 11px;
    }

    .ar-icon-box {
        width: 30px;
        height: 30px;
    }

    /* Charts: tighter cards; the stacked bar plot already scrolls inside its card */
    .ar-chart-card {
        padding: 16px;
    }

    .ar-donut-container {
        flex-direction: column;
        height: auto;
        gap: 16px;
    }

    .ar-donut-wrapper,
    .ar-donut-table-wrapper {
        width: 100%;
    }

    .ar-donut-wrapper {
        height: 220px;
    }

    /* Table: one card per row, labels from data-label */
    .ar-table-card {
        padding: 16px;
        gap: 14px;
    }

    .ar-table-top {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .ar-search-input {
        width: 100%;
        min-height: var(--tap-min, 44px);
        font-size: 16px;
    }

    .ar-table-wrapper {
        overflow-x: hidden;
        border: 0;
    }

    .ar-main-table {
        min-width: 0;
    }

        .ar-main-table thead {
            display: none;
        }

        .ar-main-table tbody,
        .ar-main-table tr,
        .ar-main-table td {
            display: block;
            width: 100%;
        }

        .ar-main-table tr {
            padding: 6px 12px;
            margin-bottom: 10px;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            background: #ffffff;
        }

        .ar-main-table td {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            padding: 8px 0;
            border-bottom: 1px solid #f1f5f9;
            font-size: 13px;
            text-align: right !important;
        }

            .ar-main-table td::before {
                content: attr(data-label);
                flex: 0 0 42%;
                color: #64748b;
                font-weight: 500;
                text-align: left;
            }

            .ar-main-table td:last-child {
                border-bottom: 0;
            }

            .ar-main-table td[data-label="S.No"] {
                display: none;
            }

            .ar-main-table td[data-label="Dealer Name"] {
                font-weight: 600;
                color: #0f172a;
            }

        .ar-main-table tr.ar-empty-row td {
            display: block;
            text-align: center !important;
        }

            .ar-main-table tr.ar-empty-row td::before {
                content: none;
            }

    .ar-action-btn {
        min-height: var(--tap-min, 44px);
        min-width: var(--tap-min, 44px);
        margin: 0;
        gap: 6px;
        padding: 0 8px;
        font-size: 13px;
        font-weight: 600;
    }

    .ar-action-text {
        display: inline;
    }

    /* Pagination: one row - Items Per Page left, pager right - same as the
       other list pages. Only prev / current / next stay visible. */
    .ar-pagination {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }

    .ar-page-controls {
        justify-content: flex-end;
        flex-wrap: nowrap;
    }

    .ar-page-btn {
        min-width: 28px;
        height: 28px;
        flex: 0 0 auto;
    }

    .ar-page-controls .ar-page-btn:not(.active):not(:first-child):not(:last-child) {
        display: none;
    }
}

/* Phone: the page's legacy header rule turned the shared PageHeader into a column, which put the
   back arrow on its own centred row above the title. Keep the shell's row layout (arrow left of
   the title, actions wrapping underneath); the repeated class only raises specificity. */
@media (max-width: 767.98px) {
    .shell-page-header.ar-header-container.ar-header-container {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
}
