/* Global Variables & Reset */
:root {
    --primary-blue: #3B82F6;
    --border-color: #E5E7EB;
    --bg-light: #F9FAFB;
    --bg-white: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
}

*, *::before, *::after {
    box-sizing: border-box;
}

.sd-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
/*    background-color: var(--bg-light);*/
    min-height: 100vh;
    padding: clamp(1rem, 3vw, 1.5rem);
    color: var(--text-main);
    box-sizing: border-box;
    width: 100%;
    overflow-x: hidden; /* Prevents body scroll if something tiny pokes out */
}

/* Page Header */
.sd-header-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.sd-header-left {
    flex: 1 1 auto;
    min-width: 280px;
    max-width: 100%;
}

.sd-title-area {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

    .sd-title-area h1 {
        font-size: clamp(1.25rem, 4vw, 1.5rem);
        font-weight: 600;
        margin: 0;
    }

.sd-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sd-badge {
    background-color: #F3F4F6;
    color: var(--text-muted);
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.sd-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

.sd-header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 0 0 auto;
    width: 100%;
}

.btn-custom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-white);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

    .btn-custom:hover {
        background-color: #F3F4F6;
    }

.btn-primary-custom {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

    .btn-primary-custom:hover {
        background-color: #2563EB;
    }

/* Cards */
.sd-card {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    overflow: hidden;
    width: 100%;
}

/* Filters Section */
.sd-filters-header {
    background-color: #F3F4F6;
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.sd-filters-body {
    padding: 1.25rem;
    width: 100%;
}

/* Collapsible filter card (desktop / tablet): the header toggles the body. */
.sd-filters-header {
    cursor: pointer;
}

.sd-filters-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.sd-filters-card--collapsed .sd-filters-chevron {
    transform: rotate(-90deg);
}

.sd-filters-card--collapsed .sd-filters-header {
    border-bottom: 0;
}

.sd-filters-card--collapsed .sd-filters-body {
    display: none;
}

/* Active-filter count shown next to "Filters" while the card is collapsed. */
.sd-filters-card .sd-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;
}

.sd-filters-grid {
    display: grid;
    /* Using min(100%, 200px) ensures it fits even if the screen is narrower than 200px */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    width: 100%;
}

.sd-form-group {
    width: 100%;
    min-width: 0;
}

    .sd-form-group label {
        display: block;
        font-size: 0.875rem;
        font-weight: 500;
        margin-bottom: 0.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.sd-form-control {
    width: 100%;
    min-width: 0; /* Forces input to shrink below its intrinsic/placeholder size */
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-main);
    background-color: var(--bg-white);
    text-overflow: ellipsis;
}

    .sd-form-control:focus {
        outline: none;
        border-color: var(--primary-blue);
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    }

.sd-filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

/* KPI Grid */
.sd-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.sd-kpi-card {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.sd-kpi-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sd-kpi-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.sd-kpi-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.sd-kpi-icon-box {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border: 1px solid;
}

.sd-kpi-purple {
    border-left: 4px solid #A855F7;
}

    .sd-kpi-purple .sd-kpi-icon-box {
        background-color: #FAF5FF;
        border-color: #E9D5FF;
        color: #A855F7;
    }

.sd-kpi-green {
    border-left: 4px solid #22C55E;
}

    .sd-kpi-green .sd-kpi-icon-box {
        background-color: #F0FDF4;
        border-color: #BBF7D0;
        color: #22C55E;
    }

.sd-kpi-yellow {
    border-left: 4px solid #EAB308;
}

    .sd-kpi-yellow .sd-kpi-icon-box {
        background-color: #FEFCE8;
        border-color: #FEF08A;
        color: #EAB308;
    }

.sd-kpi-teal {
    border-left: 4px solid #14B8A6;
}

    .sd-kpi-teal .sd-kpi-icon-box {
        background-color: #F0FDFA;
        border-color: #99F6E4;
        color: #14B8A6;
    }

/* Table Section */
.sd-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.sd-table-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.sd-search-box {
    position: relative;
    width: 100%;
    max-width: 300px;
}

    .sd-search-box i {
        position: absolute;
        left: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-muted);
    }

    .sd-search-box input {
        width: 100%;
        min-width: 0;
        padding: 0.5rem 0.75rem 0.5rem 2.25rem;
        border: 1px solid var(--border-color);
        border-radius: 0.375rem;
        font-size: 0.875rem;
        background-color: #F9FAFB;
    }

        .sd-search-box input:focus {
            outline: none;
            border-color: var(--primary-blue);
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
        }

.sd-table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sd-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px; /* Forces scroll on small screens to prevent squishing */
}

    .sd-table th, .sd-table td {
        padding: 1rem 1.25rem;
        text-align: center;
        border-bottom: 1px solid var(--border-color);
        font-size: 0.875rem;
    }

    .sd-table th {
        background-color: #F9FAFB;
        color: var(--text-main);
        font-weight: 600;
        white-space: nowrap;
    }

        .sd-table th.text-start, .sd-table td.text-start {
            text-align: left;
        }

        .sd-table th span {
            color: var(--text-muted);
            font-weight: 400;
            font-size: 0.75rem;
            display: block;
            margin-top: 0.25rem;
        }

.sd-grand-total {
    background-color: #ECFDF5;
    font-weight: 600;
}

/* Pagination */
.sd-pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.sd-page-size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

    .sd-page-size select {
        padding: 0.375rem;
        border: 1px solid var(--border-color);
        border-radius: 0.375rem;
        background-color: var(--bg-white);
    }

.sd-page-controls {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.sd-page-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-white);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-muted);
    min-width: 32px;
    text-align: center;
}

    .sd-page-btn.active {
        background-color: #F3F4F6;
        color: var(--text-main);
        font-weight: 600;
    }

    .sd-page-btn:hover:not(.ellipsis) {
        background-color: #F9FAFB;
    }

    .sd-page-btn.ellipsis {
        border: none;
        background: transparent;
        cursor: default;
    }

/* Responsive Breakpoints */
@media (min-width: 769px) {
    .sd-header-actions {
        width: auto;
    }
}

/* Tablet Portrait & Large Mobile */
@media (max-width: 768px) {
    .sd-header-section {
        flex-direction: column;
        gap: 1.25rem;
    }

    .sd-header-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

        .sd-header-actions .btn-custom {
            width: 100%;
        }

    .sd-table-header {
        flex-direction: column;
        align-items: stretch;
    }

    .sd-table-title {
        margin-bottom: 0.5rem;
    }

    .sd-search-box {
        max-width: 100%;
    }

}

/* Small Mobile */
@media (max-width: 480px) {
    .sd-title-area {
        flex-direction: column;
        align-items: flex-start;
    }

    .sd-header-actions {
        grid-template-columns: 1fr;
    }

    .sd-filter-actions {
        flex-direction: column;
        width: 100%;
    }

        .sd-filter-actions .btn-custom {
            width: 100%;
        }

    .sd-page-controls {
        gap: 0.15rem;
    }

    .sd-page-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .sd-page-controls .sd-page-btn:not(.active):not(:first-child):not(:last-child) {
        display: none;
    }
}

/* =========================================================
   Stock Details loading, Select2, and interaction states
   ========================================================= */

/* Prevent the browser's native multiple-select list box from flashing
   before Select2 creates its replacement control. */
.sd-wrapper select.sd-state-select[multiple]:not(.select2-hidden-accessible) {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    overflow: hidden !important;
    color: transparent !important;
    pointer-events: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    background-color: #FFFFFF !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 0.375rem !important;
}

.sd-wrapper .sd-form-group .select2-container {
    width: 100% !important;
    max-width: 100%;
}

.sd-wrapper .select2-container--default .select2-selection--multiple {
    min-height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--bg-white);
    padding: 3px 34px 3px 6px;
    display: flex;
    align-items: center;
    position: relative;
}

.sd-wrapper .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Force exactly one dropdown icon for Select2 multiple fields.
   Hide pseudo-elements and Select2 arrow markup coming from shared styles,
   then draw a single chevron as the selection background image. */
.sd-wrapper .select2-container--default .select2-selection--multiple::before,
.sd-wrapper .select2-container--default .select2-selection--multiple::after,
.sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__arrow,
.sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__arrow b {
    content: none !important;
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    border: 0 !important;
    background: none !important;
}

.sd-wrapper .select2-container--default .select2-selection--multiple {
    padding-right: 70px !important;
    background-color: var(--bg-white) !important;
    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%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 14px 14px !important;
}

    .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__rendered {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__choice {
        position: relative;
        display: inline-flex;
        align-items: center;
        max-width: calc(100% - 4px);
        min-height: 26px;
        margin: 0;
        padding: 3px 28px 3px 9px;
        border: 1px solid #BFDBFE;
        border-radius: 6px;
        background: #EFF6FF;
        color: #1D4ED8;
        font-size: 12px;
        line-height: 18px;
    }

    .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__choice__display {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
        position: absolute;
        right: 5px !important;
        left: auto !important;
        top: 50%;
        transform: translateY(-50%);
        width: 17px;
        height: 17px;
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
        border-left: 0 !important;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #2563EB;
        background: transparent;
        font-size: 15px;
        line-height: 1;
    }

        .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
            color: #FFFFFF;
            background: #2563EB;
        }


    /* Common clear-all button. It appears only when one or more values are selected. */
    .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__clear {
        position: absolute !important;
        top: 50% !important;
        right: 36px !important;
        z-index: 5 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 18px !important;
        height: 18px !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: translateY(-50%) !important;
        border: 0 !important;
        border-radius: 50% !important;
        background: transparent !important;
        color: transparent !important;
        font-size: 0 !important;
        line-height: 1 !important;
        cursor: pointer !important;
    }

        .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__clear::before {
            content: "\00D7" !important;
            color: #64748B !important;
            font-size: 17px !important;
            font-weight: 600 !important;
            line-height: 1 !important;
        }

        .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__clear:hover {
            background: #E2E8F0 !important;
        }

            .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__clear:hover::before {
                color: #DC2626 !important;
            }

    .sd-wrapper .select2-container--default .select2-selection--multiple .select2-selection__choice__remove > span {
        display: block !important;
        position: static !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 14px !important;
        line-height: 1 !important;
    }

.sd-wrapper .select2-container--default .select2-search--inline .select2-search__field {
    height: 28px;
    margin: 0;
    padding: 3px 4px;
    font-family: inherit;
    font-size: 13px;
}

.sd-wrapper .select2-container--disabled .select2-selection--multiple {
    cursor: not-allowed;
    background: #F3F4F6;
    opacity: 0.75;
}

.btn-custom:disabled,
.sd-page-btn:disabled,
.sd-form-control:disabled,
.sd-search-box input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.sd-dashboard-shell {
    position: relative;
}

    .sd-dashboard-shell.is-updating > .sd-kpi-grid,
    .sd-dashboard-shell.is-updating > .sd-card {
        opacity: 0.58;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

.sd-update-indicator {
    position: absolute;
    top: -12px;
    right: 0;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border: 1px solid #BFDBFE;
    border-radius: 999px;
    background: #EFF6FF;
    color: #1D4ED8;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
    font-size: 12px;
    font-weight: 600;
}

.sd-update-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #BFDBFE;
    border-top-color: #2563EB;
    border-radius: 50%;
    animation: sd-spin 0.75s linear infinite;
}

.sd-inline-error {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #FED7AA;
    border-radius: 8px;
    background: #FFF7ED;
    color: #C2410C;
    font-size: 12px;
    font-weight: 500;
}

.sd-empty-state {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 20px;
    border: 1px dashed #CBD5E1;
    border-radius: 12px;
    background: #FFFFFF;
    color: #64748B;
    text-align: center;
}

    .sd-empty-state > i {
        font-size: 30px;
        color: #F59E0B;
    }

.sd-loading-layout {
    width: 100%;
}

.sd-skeleton-card {
    border-left-color: #E2E8F0;
    background: #FFFFFF;
}

.sd-skeleton {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    background: #E9EEF5;
}

    .sd-skeleton::after {
        content: "";
        position: absolute;
        inset: 0;
        transform: translateX(-100%);
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
        animation: sd-shimmer 1.35s infinite;
    }

.sd-skeleton-label {
    width: 86px;
    height: 13px;
}

.sd-skeleton-value {
    width: 116px;
    height: 25px;
}

.sd-skeleton-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
}

.sd-skeleton-table-card {
    min-height: 420px;
}

.sd-skeleton-title {
    width: 135px;
    height: 20px;
}

.sd-skeleton-search {
    width: min(300px, 100%);
    height: 38px;
}

.sd-skeleton-table {
    padding: 0 1.25rem 1.25rem;
}

.sd-skeleton-table-head {
    width: 100%;
    height: 48px;
    margin-bottom: 8px;
    border-radius: 8px;
}

.sd-skeleton-row {
    display: grid;
    grid-template-columns: 1.5fr repeat(5, 1fr);
    gap: 18px;
    align-items: center;
    min-width: 760px;
    padding: 15px 12px;
    border-bottom: 1px solid #F1F5F9;
}

.sd-skeleton-cell {
    width: 70%;
    height: 13px;
    justify-self: center;
}

.sd-skeleton-cell-wide {
    width: 84%;
    justify-self: start;
}

@keyframes sd-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes sd-shimmer {
    100% {
        transform: translateX(100%);
    }
}

@media (max-width: 768px) {
    .sd-update-indicator {
        position: static;
        width: fit-content;
        margin: 0 0 12px auto;
    }

    .sd-skeleton-row {
        gap: 12px;
    }
}

/* ========================================================
   PageHeader adoption: the old header put the title, the two date
   badges and the subtitle on the left and the buttons on the right.
   Now: PageHeader (title / subtitle / buttons) with the badges row
   directly under it; typography matches the old h1 / .sd-subtitle.
   ======================================================== */
.sd-wrapper .sd-header-section {
    display: block;
}

.sd-wrapper .shell-page-header.sd-page-header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 0 0 0.75rem;
}

    .sd-wrapper .shell-page-header.sd-page-header .shell-page-title {
        font-size: clamp(1.25rem, 4vw, 1.5rem);
        font-weight: 600;
        line-height: 1.2;
        color: var(--text-main);
        margin: 0;
    }

    .sd-wrapper .shell-page-header.sd-page-header .shell-page-subtitle {
        color: var(--text-muted);
        font-size: 0.875rem;
        margin-top: 0.75rem;
    }

    .sd-wrapper .shell-page-header.sd-page-header .shell-page-actions {
        gap: 0.75rem;
        flex-wrap: wrap;
    }

.sd-wrapper .sd-header-section > .sd-badges {
    margin-bottom: 1.5rem;
}

.sd-empty-state .spic-empty {
    width: 100%;
}

/* native: phone */
@media (max-width: 767.98px) {
    .sd-wrapper {
        padding: 12px 16px calc(16px + var(--safe-bottom, 0px));
        min-height: 0;
    }

    .sd-wrapper .shell-page-header.sd-page-header {
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
    }

        .sd-wrapper .shell-page-header.sd-page-header .shell-page-title {
            font-size: 1.15rem;
        }

        .sd-wrapper .shell-page-header.sd-page-header .shell-page-subtitle {
            font-size: 0.8rem;
            margin-top: 2px;
        }

        .sd-wrapper .shell-page-header.sd-page-header .shell-page-actions {
            flex-basis: 100%;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }

    .sd-wrapper .sd-header-section > .sd-badges {
        margin-bottom: 1rem;
    }

    .sd-badge {
        white-space: normal;
    }

    .sd-wrapper .btn-custom {
        min-height: var(--tap-min, 44px);
        width: 100%;
    }

    /* Filters trigger (opens the BottomSheet) */
    .sd-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: 1.25rem;
        background: var(--bg-white);
        border: 1px solid var(--border-color);
        border-radius: 0.75rem;
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        color: var(--text-main);
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        text-align: left;
    }

        .sd-filter-trigger:disabled {
            opacity: 0.6;
        }

    .sd-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: var(--primary-blue);
        color: #ffffff;
        font-size: 12px;
        font-weight: 600;
    }

    /* Filter fields inside the sheet: one column, native multi-selects visible */
    .sd-wrapper .sd-filter-sheet .sd-filters-body {
        padding: 0;
    }

    .sd-wrapper .sd-filter-sheet .sd-filters-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 0;
    }

    .sd-wrapper .sd-filter-sheet select.sd-state-select[multiple] {
        height: auto !important;
        min-height: var(--tap-min, 44px) !important;
        max-height: 168px !important;
        padding: 6px 8px !important;
        overflow: auto !important;
        color: var(--text-main) !important;
        pointer-events: auto !important;
        appearance: auto !important;
        -webkit-appearance: auto !important;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

        .sd-wrapper .sd-filter-sheet select.sd-state-select[multiple] option {
            padding: 8px 6px;
        }

    .sd-wrapper .sd-filter-sheet .sd-form-control {
        min-height: var(--tap-min, 44px);
        font-size: 16px;
    }

    .sd-wrapper .sd-filter-sheet .btn-custom {
        width: auto;
    }

    /* KPI tiles: two per row */
    .sd-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        margin-bottom: 1rem;
    }

    .sd-kpi-card {
        padding: 14px;
    }

    .sd-kpi-label {
        font-size: 0.75rem;
    }

    .sd-kpi-value {
        font-size: 18px;
    }

    .sd-kpi-icon-box {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* Table: one card per state, labels from data-label */
    .sd-table-header {
        padding: 16px;
        gap: 12px;
    }

    .sd-search-box input {
        min-height: var(--tap-min, 44px);
        font-size: 16px;
    }

    .sd-wrapper .sd-table-responsive {
        overflow-x: hidden;
    }

    .sd-wrapper .sd-table {
        min-width: 0;
    }

        .sd-wrapper .sd-table thead {
            display: none;
        }

        .sd-wrapper .sd-table tbody,
        .sd-wrapper .sd-table tr,
        .sd-wrapper .sd-table td {
            display: block;
            width: 100%;
        }

        .sd-wrapper .sd-table tr {
            padding: 6px 16px;
            border-bottom: 8px solid #f1f5f9;
        }

            .sd-wrapper .sd-table tr:last-child {
                border-bottom: 0;
            }

        .sd-wrapper .sd-table td {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            padding: 8px 0;
            border-bottom: 1px solid #f1f5f9;
            font-size: 0.8rem;
            text-align: right !important;
        }

            .sd-wrapper .sd-table td::before {
                content: attr(data-label);
                flex: 0 0 48%;
                color: var(--text-muted);
                font-weight: 500;
                text-align: left;
            }

            .sd-wrapper .sd-table td:last-child {
                border-bottom: 0;
            }

            .sd-wrapper .sd-table td[data-label="State"] {
                font-weight: 600;
                color: var(--text-main);
            }

        .sd-wrapper .sd-table tr.sd-grand-total td[data-label="State"] {
            font-weight: 700;
        }

        .sd-wrapper .sd-table tr.sd-empty-row td {
            display: block;
            text-align: center !important;
        }

            .sd-wrapper .sd-table tr.sd-empty-row td::before {
                content: none;
            }

    /* Pagination: one row - Items Per Page left, pager right - same as the
       Top Ranking list pages. Only prev / current / next stay visible. */
    .sd-pagination-bar {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        gap: 8px;
        text-align: left;
    }

    .sd-page-size {
        white-space: nowrap;
    }

    .sd-page-controls {
        flex-wrap: nowrap;
        justify-content: flex-end;
    }

    .sd-page-btn {
        min-width: 32px;
        min-height: 32px;
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        flex: 0 0 auto;
    }

    .sd-page-controls .sd-page-btn:not(.active):not(:first-child):not(:last-child) {
        display: none;
    }
}
