﻿
/* ── CSS Variables ─────────────────────────────────────── */
:root {
    --kcl-gold: #f0b429;
    --kcl-gold-dark: #d4a017;
    --kcl-gold-light: #fef3dc;
    --ms-blue: #2c5f7f;
    --ms-blue-dark: #1f4a61;
    --ms-blue-light: #e8f1f5;
    --ms-bg: #f8f9fa;
    --ms-white: #ffffff;
    --ms-text: #2d3748;
    --ms-text-secondary: #4a5568;
    --ms-text-muted: #718096;
    --ms-border: #d1d5db;
    --ms-border-light: #e5e7eb;
    --ms-success: #107C10;
    --ms-danger: #D13438;
    --ms-warning: #FFB900;
    --ms-shadow: 0 2px 8px rgba(0,0,0,.08);
    --ms-shadow-lg: 0 6px 20px rgba(0,0,0,.1);
    --ms-radius: 8px;
    --ms-radius-sm: 4px;
    --ms-transition: all .2s ease;
}

/* ── Page Layout ───────────────────────────────────────── */
.billing-page {
    background: var(--ms-bg);
    padding: 24px 20px;
    min-height: 100vh;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ms-text);
    overflow-x: hidden;
    max-width: 100vw;
    box-sizing: border-box;
}

    .billing-page .row {
        display: block;
    }

/* ── Page Header ───────────────────────────────────────── */
.page-header-modern {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    padding: 20px 24px;
    border-radius: var(--ms-radius);
    margin-bottom: 20px;
    box-shadow: var(--ms-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    border: 1px solid var(--ms-border-light);
    border-bottom: 3px solid var(--kcl-gold);
}

    .page-header-modern h3 {
        font-size: 26px;
        font-weight: 600;
        color: var(--ms-text);
        margin: 0;
        letter-spacing: -.3px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

        .page-header-modern h3 .glyphicon {
            color: var(--kcl-gold) !important;
        }

    .page-header-modern .header-actions {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
    }

/* ── Alerts ────────────────────────────────────────────── */
.alert-modern {
    border: none;
    border-radius: var(--ms-radius);
    padding: 14px 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    box-shadow: var(--ms-shadow);
}

    .alert-modern.alert-success {
        background: #DFF6DD;
        color: #0B6A0B;
        border-left: 4px solid var(--ms-success);
    }

    .alert-modern.alert-danger {
        background: #FDE7E9;
        color: #A80000;
        border-left: 4px solid var(--ms-danger);
    }

    .alert-modern .close {
        margin-left: auto;
        opacity: .6;
        font-size: 18px;
        color: inherit;
    }

/* ── Filter Card ───────────────────────────────────────── */
.filter-card {
    background: var(--ms-white);
    border-radius: var(--ms-radius);
    box-shadow: var(--ms-shadow);
    padding: 20px 24px;
    margin-bottom: 20px;
    border: 1px solid var(--ms-border-light);
}

    .filter-card .filter-row {
        display: flex;
        align-items: flex-end;
        gap: 12px;
        flex-wrap: wrap;
    }

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 62px;
    justify-content: flex-end;
}

    .filter-group label,
    .filter-label {
        font-size: 12px;
        font-weight: 600;
        color: var(--ms-text-secondary);
        text-transform: uppercase;
        letter-spacing: .5px;
        margin-bottom: 4px;
    }

.filter-card .form-control {
    border: 1px solid var(--ms-border);
    border-radius: var(--ms-radius-sm);
    height: 36px;
    font-size: 14px;
    color: var(--ms-text);
    padding: 4px 10px;
    transition: var(--ms-transition);
    background: var(--ms-white);
}

    .filter-card .form-control:focus {
        border-color: var(--kcl-gold);
        box-shadow: 0 0 0 2px rgba(240,180,41,.15);
        outline: none;
    }

.filter-card select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23605E5C' d='M6 8.825L1.175 4 2.238 2.938 6 6.7 9.763 2.937 10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

/* ── Date Filter ───────────────────────────────────────── */
.date-filter-section {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

    .date-filter-section .date-check {
        display: flex;
        align-items: center;
        gap: 6px;
        padding-bottom: 6px;
    }

        .date-filter-section .date-check input[type="checkbox"],
        .filter-check-item input[type="checkbox"] {
            width: 18px;
            height: 18px;
            cursor: pointer;
            accent-color: var(--kcl-gold);
        }

    .date-filter-section .date-inputs {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }

        .date-filter-section .date-inputs span {
            font-size: 13px;
            color: var(--ms-text-secondary);
            font-weight: 500;
        }

        .date-filter-section .date-inputs input {
            width: 120px !important;
        }

/* ── Checkbox Filters ──────────────────────────────────── */
.filter-checkboxes {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-check-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ms-text);
    cursor: pointer;
    white-space: nowrap;
    padding: 2px 0;
}

    .filter-check-item label {
        margin: 0;
        font-weight: 500;
        cursor: pointer;
        font-size: 13px;
    }

/* ── Buttons ───────────────────────────────────────────── */
.btn-ms-primary {
    background: var(--ms-blue);
    color: #fff;
    border: 1px solid var(--ms-blue-dark);
    border-radius: var(--ms-radius-sm);
    padding: 8px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ms-transition);
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .btn-ms-primary:hover,
    .btn-ms-primary:focus {
        background: var(--ms-blue-dark);
        color: #fff;
        text-decoration: none;
    }

/* Green — Import pages */
.btn-ms-success {
    background: var(--ms-success);
    color: #fff !important;
    border: none;
    border-radius: var(--ms-radius-sm);
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ms-transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

    .btn-ms-success:hover,
    .btn-ms-success:focus {
        background: #0B6A0B;
        color: #fff !important;
        text-decoration: none;
    }

/* Red — Export pages */
.btn-ms-danger {
    background: var(--ms-danger);
    color: #fff !important;
    border: none;
    border-radius: var(--ms-radius-sm);
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ms-transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

    .btn-ms-danger:hover,
    .btn-ms-danger:focus {
        background: #A80000;
        color: #fff !important;
        text-decoration: none;
    }

/* ── Stats Bar ─────────────────────────────────────────── */
.stats-bar {
    background: var(--ms-white);
    border-radius: var(--ms-radius);
    box-shadow: var(--ms-shadow);
    padding: 14px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    border: 1px solid var(--ms-border-light);
}

    .stats-bar .stats-left,
    .stats-bar .stats-right {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    transition: var(--ms-transition);
    text-decoration: none !important;
    cursor: pointer;
    border: none;
    background: none;
}

    .stat-chip:hover {
        transform: translateY(-1px);
        box-shadow: 0 3px 8px rgba(0,0,0,.12);
        text-decoration: none !important;
    }

    .stat-chip.stat-date {
        background: var(--kcl-gold-light);
        color: var(--ms-text);
        cursor: default;
        border: 1px solid var(--kcl-gold-dark);
    }

        .stat-chip.stat-date:hover {
            transform: none;
            box-shadow: none;
        }

    .stat-chip.stat-pending {
        background: #FFF4CE;
        color: #835C00;
    }

        .stat-chip.stat-pending:hover {
            background: #FFE999;
        }

    .stat-chip.stat-rejected {
        background: #FDE7E9;
        color: #A80000;
    }

        .stat-chip.stat-rejected:hover {
            background: #FCCFD1;
        }

    .stat-chip .stat-count {
        background: rgba(0,0,0,.08);
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 12px;
    }

/* ── Table ─────────────────────────────────────────────── */
.table-wrapper {
    background: var(--ms-white);
    border-radius: var(--ms-radius);
    box-shadow: var(--ms-shadow);
    border: 1px solid var(--ms-border-light);
    overflow: hidden;
    margin-bottom: 20px;
}

.table-responsive-modern {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.billing-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 13px;
}

    .billing-table thead {
        background: linear-gradient(135deg, var(--ms-blue), var(--ms-blue-dark));
        border-bottom: 2px solid var(--kcl-gold);
    }

        .billing-table thead th {
            color: #fff;
            font-weight: 600;
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: .5px;
            padding: 14px 12px;
            white-space: nowrap;
            border: none;
            position: sticky;
            top: 0;
            z-index: 1;
        }

            .billing-table thead th a {
                color: #fff !important;
                text-decoration: none;
                display: inline-flex;
                align-items: center;
                gap: 4px;
            }

                .billing-table thead th a:hover {
                    color: var(--kcl-gold-light) !important;
                }

    .billing-table tbody tr {
        border-bottom: 1px solid var(--ms-border-light);
        transition: var(--ms-transition);
    }

        .billing-table tbody tr:hover {
            background: var(--ms-blue-light);
        }

        .billing-table tbody tr:last-child {
            border-bottom: none;
        }

    .billing-table td {
        padding: 12px;
        vertical-align: middle;
        color: var(--ms-text);
        border: none;
    }

    .billing-table .row-number {
        color: var(--ms-text-muted);
        font-size: 12px;
        font-weight: 600;
        text-align: center;
        width: 40px;
    }

/* ── Date / Time cells ─────────────────────────────────── */
.main-date {
    font-size: .95rem;
    line-height: 1.15;
    font-weight: 500;
    color: var(--ms-text);
}

.time-line {
    line-height: 1.1;
    margin-top: 2px;
    white-space: nowrap;
    color: #6f42c1;
    opacity: .9;
}

    .time-line .time {
        font-size: .88rem;
        font-weight: 500;
    }

    .time-line .ampm {
        font-size: .88rem;
        margin-left: 3px;
        letter-spacing: .04em;
        text-transform: uppercase;
        opacity: .85;
    }

/* ── Special Cells ─────────────────────────────────────── */
.dec-link {
    color: var(--ms-blue);
    font-weight: 600;
    text-decoration: none;
    transition: var(--ms-transition);
}

    .dec-link:hover {
        color: var(--ms-blue-dark);
        text-decoration: underline;
    }

.invoice-cell {
    max-width: 130px;
    position: relative;
}

.invoice-text {
    display: block;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.invoice-eye-btn {
    display: none;
    background: none;
    border: none;
    color: var(--kcl-gold-dark);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 14px;
    vertical-align: middle;
    margin-left: 2px;
}

    .invoice-eye-btn:hover {
        color: var(--ms-blue);
    }

.invoice-cell.is-overflowing .invoice-eye-btn {
    display: inline-block;
}

.invoice-cell.is-overflowing .invoice-text {
    display: inline-block;
    vertical-align: middle;
}

.beneficiary-cell {
    position: relative;
    min-width: 120px;
    white-space: nowrap;
}

.beneficiary-text {
    display: inline-block;
    max-width: 85px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    vertical-align: middle;
}

.beneficiary-icon-btn {
    display: inline-block;
    background: none;
    border: none;
    color: var(--kcl-gold-dark);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 13px;
    vertical-align: middle;
    margin-left: 4px;
}

    .beneficiary-icon-btn:hover {
        color: var(--ms-blue);
    }

.port-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.port-abbr {
    font-weight: 600;
    font-size: 12px;
    background: var(--ms-blue-light);
    padding: 3px 8px;
    border-radius: var(--ms-radius-sm);
    border: 1px solid var(--ms-blue);
}

.port-transport {
    font-size: 16px;
    color: var(--ms-text-secondary);
}

    .port-transport img {
        width: 18px;
        height: 18px;
        opacity: .7;
    }

.container-count {
    font-weight: 600;
    font-size: 13px;
    text-align: center;
}

.amount-cell {
    text-align: center;
}

.amount-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.amount-value {
    font-weight: 600;
    font-size: 13px;
    color: var(--ms-text);
}

.payment-icon-modern {
    font-size: 16px !important;
}

.prod-link {
    background: var(--ms-blue-light);
    color: var(--ms-blue) !important;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    transition: var(--ms-transition);
    display: inline-block;
    border: 1px solid var(--ms-blue);
}

    .prod-link:hover {
        background: var(--ms-blue);
        color: #fff !important;
    }

/* ── Action Buttons ────────────────────────────────────── */
.actions-cell {
    white-space: nowrap;
}

    .actions-cell .action-group {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        flex-wrap: nowrap;
    }

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--ms-radius-sm);
    font-size: 13px;
    text-decoration: none !important;
    transition: var(--ms-transition);
    border: 1px solid transparent;
}

    .action-btn:hover {
        text-decoration: none !important;
    }

.btn-action-add {
    color: var(--ms-success);
    background: #DFF6DD;
    border-color: #C8E6C9;
}

    .btn-action-add:hover {
        background: var(--ms-success);
        color: #fff;
    }

.btn-action-receipt-paid {
    color: #fff;
    background: var(--ms-success);
}

    .btn-action-receipt-paid:hover {
        background: #0B6A0B;
        color: #fff;
    }

.btn-action-receipt-unpaid {
    color: #fff;
    background: var(--ms-danger);
}

    .btn-action-receipt-unpaid:hover {
        background: #A80000;
        color: #fff;
    }

.btn-action-receipt-na {
    color: var(--ms-text-muted);
    background: transparent;
    border-color: var(--ms-border);
}

.btn-action-edit {
    color: var(--ms-blue);
    background: var(--ms-blue-light);
    border-color: var(--ms-blue);
}

    .btn-action-edit:hover {
        background: var(--ms-blue);
        color: #fff;
    }

.btn-action-delete {
    color: var(--ms-danger);
    background: #FDE7E9;
    border-color: #F5C2C5;
}

    .btn-action-delete:hover {
        background: var(--ms-danger);
        color: #fff;
    }

.btn-action-locked {
    color: var(--ms-text-muted);
    background: #F3F2F1;
    border-color: var(--ms-border);
    cursor: not-allowed;
}

/* ── Status Icon Buttons ───────────────────────────────── */
.status-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--ms-radius-sm);
    font-size: 14px;
    border: 1px solid transparent;
    text-decoration: none !important;
}

    .status-icon-btn.doc-yes {
        color: var(--ms-success);
        background: #DFF6DD;
        border-color: #C8E6C9;
    }

    .status-icon-btn.doc-no {
        color: var(--ms-danger);
        background: #FDE7E9;
        border-color: #F5C2C5;
    }

    .status-icon-btn.kepa-approved {
        color: var(--ms-success);
        background: #DFF6DD;
        border-color: #C8E6C9;
    }

    .status-icon-btn.kepa-pending {
        color: var(--ms-warning);
        background: #FFF4CE;
        border-color: #FFE999;
    }

    .status-icon-btn.kepa-update,
    .status-icon-btn.kepa-notsend,
    .status-icon-btn.kepa-alert {
        color: var(--ms-danger);
        background: #FDE7E9;
        border-color: #F5C2C5;
    }

.status-divider {
    color: var(--ms-border);
    font-size: 16px;
    margin: 0 2px;
}

.green-icon {
    color: green;
}

.red-icon {
    color: red;
}

/* ── Inspection Badges ─────────────────────────────────── */
.insp-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    white-space: nowrap;
}

    .insp-badge .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        display: inline-block;
    }

.badge-default {
    background: #f1f3f5;
    color: #495057;
    border-color: #dee2e6;
}

    .badge-default .dot {
        background: #6c757d;
    }

.badge-chem {
    background: #f3e8ff;
    color: #5b21b6;
    border-color: #e9d5ff;
}

    .badge-chem .dot {
        background: #7c3aed;
    }

.badge-phy {
    background: #e7f1ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

    .badge-phy .dot {
        background: #2563eb;
    }

.badge-both {
    background: #eafaf1;
    color: #166534;
    border-color: #bbf7d0;
}

    .badge-both .dot {
        background: #22c55e;
    }

.badge-nuk {
    background: #f1f3f5;
    color: #212529;
    border-color: #ced4da;
}

    .badge-nuk .dot {
        background: #343a40;
    }

.badge-l50 {
    background: #fff4e6;
    color: #9a3412;
    border-color: #fed7aa;
}

    .badge-l50 .dot {
        background: #f97316;
    }

/* ── Pagination ────────────────────────────────────────── */
.pagination-wrapper {
    background: var(--ms-white);
    border-radius: var(--ms-radius);
    box-shadow: var(--ms-shadow);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    border: 1px solid var(--ms-border-light);
    margin-bottom: 16px;
}

.pagination-info {
    font-size: 13px;
    color: var(--ms-text-secondary);
    font-weight: 500;
}

.pagination-wrapper .pagination {
    margin: 0;
}

    .pagination-wrapper .pagination > li > a,
    .pagination-wrapper .pagination > li > span {
        color: var(--ms-blue);
        border-color: var(--ms-border);
        border-radius: var(--ms-radius-sm) !important;
        margin: 0 2px;
        padding: 6px 12px;
        font-size: 13px;
        transition: var(--ms-transition);
    }

        .pagination-wrapper .pagination > li > a:hover {
            background: var(--ms-blue-light);
            border-color: var(--ms-blue);
            color: var(--ms-blue-dark);
        }

    .pagination-wrapper .pagination > .active > a,
    .pagination-wrapper .pagination > .active > span {
        background: var(--ms-blue) !important;
        border-color: var(--ms-blue) !important;
        color: #fff !important;
    }

    .pagination-wrapper .pagination > .disabled > a,
    .pagination-wrapper .pagination > .disabled > span {
        color: var(--ms-text-muted);
        background: #F3F2F1;
    }

/* ── Total Amount Bar ──────────────────────────────────── */
.total-amount-bar {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    color: var(--ms-text);
    padding: 12px 24px;
    border-radius: var(--ms-radius);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 20px;
    box-shadow: var(--ms-shadow);
    border: 1px solid var(--ms-border-light);
    border-left: 4px solid var(--kcl-gold);
}

/* ── Modals ────────────────────────────────────────────── */
.modal-modern .modal-content {
    border-radius: var(--ms-radius);
    border: none;
    box-shadow: var(--ms-shadow-lg);
    overflow: hidden;
}

.modal-modern .modal-header {
    background: linear-gradient(135deg,#fff,#f8f9fa);
    color: var(--ms-text);
    border-bottom: 2px solid var(--kcl-gold);
    padding: 16px 24px;
}

    .modal-modern .modal-header .close {
        color: var(--ms-text);
        opacity: .6;
        text-shadow: none;
    }

        .modal-modern .modal-header .close:hover {
            opacity: 1;
        }

.modal-modern .modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ms-text);
}

    .modal-modern .modal-title .glyphicon {
        color: var(--kcl-gold);
    }

.modal-modern .modal-body {
    padding: 20px 24px;
}

    .modal-modern .modal-body .table {
        margin-bottom: 0;
    }

        .modal-modern .modal-body .table th {
            background: var(--ms-blue-light);
            color: var(--ms-blue-dark);
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: .5px;
            border: none;
            padding: 10px 12px;
            border-bottom: 2px solid var(--ms-blue);
        }

        .modal-modern .modal-body .table td {
            border-color: var(--ms-border-light);
            padding: 10px 12px;
            font-size: 13px;
        }

.modal-modern .modal-footer {
    border-top: 1px solid var(--ms-border-light);
    padding: 12px 24px;
}

    .modal-modern .modal-footer .btn {
        border-radius: var(--ms-radius-sm);
    }

.invoice-popover-modal .modal-dialog,
.beneficiary-popover-modal .modal-dialog {
    max-width: 400px;
}

.invoice-popover-modal .modal-body,
.beneficiary-popover-modal .modal-body {
    font-size: 14px;
    word-break: break-word;
    line-height: 1.6;
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════ */

@media screen and (max-width: 1200px) {
    .billing-table {
        font-size: 12px;
    }

        .billing-table thead th {
            font-size: 11px;
            padding: 10px 8px;
        }

        .billing-table td {
            padding: 10px 8px;
        }
}

@media screen and (max-width: 992px) {
    .filter-card .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

        .filter-group .form-control,
        .filter-group select.form-control {
            width: 100% !important;
        }

    .date-filter-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-checkboxes {
        flex-wrap: wrap;
    }

    .stats-bar {
        flex-direction: column;
        align-items: flex-start;
    }

        .stats-bar .stats-left,
        .stats-bar .stats-right {
            width: 100%;
            justify-content: flex-start;
        }
}

@media screen and (max-width: 768px) {
    .billing-page {
        padding: 8px 6px;
        overflow-x: hidden;
    }

    .page-header-modern {
        padding: 16px 12px;
    }

        .page-header-modern h3 {
            font-size: 18px;
        }

        .page-header-modern .header-actions {
            width: 100%;
        }

            .page-header-modern .header-actions a {
                flex: 1;
                text-align: center;
                padding: 8px;
                font-size: 12px;
            }

    .filter-card {
        padding: 12px 10px;
    }

    .filter-label {
        font-size: 11px;
    }

    .filter-group .form-control,
    .filter-group select.form-control {
        width: 100% !important;
        font-size: 13px;
        height: 36px;
    }

    .filter-checkboxes {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px 8px;
    }

    .filter-check-item {
        font-size: 11px;
    }

    .btn-ms-primary {
        width: 100%;
        justify-content: center;
        height: 38px;
        font-size: 14px;
    }

    .stats-bar {
        padding: 8px 10px;
        flex-direction: column;
        gap: 6px;
    }

        .stats-bar .stats-left,
        .stats-bar .stats-right {
            width: 100%;
        }

    .stat-chip {
        font-size: 11px;
        padding: 5px 8px;
        flex: 1;
        justify-content: center;
    }

        .stat-chip .stat-count {
            font-size: 10px;
            padding: 1px 5px;
        }

    .pagination-wrapper {
        flex-direction: column;
        text-align: center;
        padding: 10px;
    }

    .pagination-info {
        font-size: 12px;
    }

    .pagination-wrapper .pagination > li > a,
    .pagination-wrapper .pagination > li > span {
        padding: 4px 8px;
        font-size: 11px;
    }

    .total-amount-bar {
        font-size: 13px;
        text-align: center;
        padding: 10px 12px;
    }

    .modal-modern .modal-dialog {
        margin: 10px;
    }

    /* Date filter mobile */
    .date-filter-section {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

        .date-filter-section .date-check {
            padding-bottom: 0;
        }

        .date-filter-section .date-inputs {
            display: flex;
            flex-wrap: nowrap;
            align-items: center;
            gap: 4px;
        }

            .date-filter-section .date-inputs input {
                flex: 1;
                min-width: 0;
                width: auto !important;
                font-size: 12px;
                padding: 4px 6px;
            }

            .date-filter-section .date-inputs span {
                flex-shrink: 0;
                font-size: 11px;
            }

            .date-filter-section .date-inputs .ui-datepicker-trigger {
                width: 20px;
                height: 20px;
                vertical-align: middle;
                flex-shrink: 0;
            }

    /* Mobile card layout */
    .table-wrapper {
        background: transparent;
        box-shadow: none;
        border: none;
        margin-left: -8px;
        margin-right: -8px;
        border-radius: 0;
        overflow: hidden;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .table-responsive-modern {
        overflow-x: hidden;
        overflow-y: visible;
    }

    .billing-table thead {
        display: none;
    }

    .billing-table,
    .billing-table tbody,
    .billing-table tr,
    .billing-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

        .billing-table tbody tr {
            background: var(--ms-white);
            border: 1px solid var(--ms-border-light);
            border-left: 3px solid var(--kcl-gold);
            border-radius: var(--ms-radius);
            margin-bottom: 10px;
            padding: 10px;
            box-shadow: var(--ms-shadow);
            max-width: 100%;
            word-break: break-word;
            overflow-wrap: break-word;
        }

            .billing-table tbody tr:hover {
                background: var(--ms-white);
                box-shadow: var(--ms-shadow-lg);
            }

        .billing-table td {
            padding: 3px 0;
            border: none;
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 4px;
            font-size: 11.5px;
            word-break: break-word;
            overflow: hidden;
        }

            .billing-table td::before {
                content: attr(data-label);
                font-weight: 600;
                font-size: 10px;
                text-transform: uppercase;
                letter-spacing: .3px;
                color: var(--ms-text-secondary);
                min-width: 80px;
                max-width: 80px;
                flex-shrink: 0;
                padding-top: 1px;
                line-height: 1.5;
            }

            .billing-table td > * {
                text-align: right;
                margin-left: auto;
                flex: 1;
                min-width: 0;
                overflow-wrap: break-word;
                word-break: break-word;
                white-space: normal;
                overflow: hidden;
            }

            .billing-table td.row-number {
                display: none;
            }

            .billing-table td.actions-cell {
                border-top: 1px solid var(--ms-border-light);
                padding-top: 8px;
                margin-top: 4px;
                justify-content: center;
            }

                .billing-table td.actions-cell::before {
                    display: none;
                }

    .actions-cell .action-group {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .action-btn, .status-icon-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .status-divider {
        margin: 0 1px;
        font-size: 14px;
    }

    .invoice-cell {
        max-width: none;
    }

    .invoice-text {
        max-width: none;
        white-space: normal;
    }

    .invoice-cell.is-overflowing .invoice-eye-btn {
        display: none;
    }

    .beneficiary-cell .beneficiary-text {
        max-width: none;
        white-space: normal;
    }

    .amount-inner {
        flex-direction: column;
        align-items: flex-end;
        gap: 1px;
    }

    .amount-value {
        font-size: 12px;
    }

    .payment-icon-modern {
        font-size: 13px !important;
    }

    .port-cell {
        justify-content: flex-end;
    }

    .port-abbr {
        font-size: 10px;
        padding: 2px 5px;
    }

    .container-count {
        text-align: right;
        font-size: 12px;
    }

    .dec-link {
        font-size: 12px;
    }

    .prod-link {
        font-size: 11px;
        padding: 3px 8px;
    }
}

@media screen and (max-width: 400px) {
    .billing-page {
        padding: 6px 4px;
    }

    .page-header-modern {
        padding: 12px 10px;
    }

        .page-header-modern h3 {
            font-size: 16px;
        }

    .filter-card {
        padding: 10px 8px;
    }

    .filter-checkboxes {
        grid-template-columns: 1fr 1fr;
        gap: 4px 6px;
    }

    .filter-check-item {
        font-size: 10px;
    }

    .billing-table td::before {
        min-width: 70px;
        max-width: 70px;
        font-size: 9px;
    }

    .billing-table td {
        font-size: 10.5px;
    }

    .billing-table tbody tr {
        padding: 8px;
    }

    .action-btn, .status-icon-btn {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
}
