/* CONNECTOR_PROJECT_RECEIVABLES_CSS_V1 */

.receivables-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.receivables-header h1 {
    margin: 0 0 6px;
    color: #0f172a;
}

.receivables-header p {
    margin: 0;
    color: #64748b;
}

.receivables-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.receivables-header-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    min-height: 44px;
    margin: 0;
    padding: 10px 15px;

    border: 0;
    border-radius: 12px;

    background: #2563eb;
    color: #ffffff;

    font-weight: 900;
    cursor: pointer;
}

.receivables-summary {
    display: grid;
    grid-template-columns:
        repeat(
            6,
            minmax(0, 1fr)
        );

    gap: 12px;
    margin-bottom: 18px;
}

.receivables-summary article {
    min-width: 0;
    padding: 15px;

    border: 1px solid #e2e8f0;
    border-radius: 17px;

    background: #ffffff;

    box-shadow:
        0 8px 22px
        rgba(15, 23, 42, 0.06);
}

.receivables-summary span {
    display: block;

    color: #64748b;

    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.receivables-summary strong {
    display: block;
    margin-top: 7px;

    color: #0f172a;

    font-size: 20px;
    line-height: 1.15;

    overflow-wrap: anywhere;
}

.receivables-summary article.overdue {
    border-top: 4px solid #ef4444;
}

.receivables-summary article.disputed {
    border-top: 4px solid #f59e0b;
}

.receivables-summary article.retention {
    border-top: 4px solid #8b5cf6;
}

.receivables-panel {
    padding: 16px;

    border: 1px solid #e2e8f0;
    border-radius: 20px;

    background: #ffffff;

    box-shadow:
        0 10px 26px
        rgba(15, 23, 42, 0.06);
}

.receivables-filters {
    display: grid;

    grid-template-columns:
        minmax(240px, 1.6fr)
        repeat(4, minmax(150px, 1fr))
        46px;

    gap: 9px;
    margin-bottom: 14px;
}

.receivables-filters input,
.receivables-filters select {
    width: 100%;
    min-width: 0;
    min-height: 44px;

    padding: 10px 12px;

    box-sizing: border-box;

    border: 1px solid #cbd5e1;
    border-radius: 12px;

    background: #f8fafc;
}

.receivables-filters button {
    width: 46px;
    height: 44px;

    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 12px;

    background: #0f172a;
    color: #ffffff;

    cursor: pointer;
}

.receivables-table-wrap {
    overflow: auto;

    border: 1px solid #e5e7eb;
    border-radius: 15px;
}

.receivables-table {
    min-width: 1650px;

    margin: 0;

    border-radius: 0;
    box-shadow: none;
}

.receivables-table tr {
    cursor: pointer;
}

.receivables-table tr:hover td {
    background: #eff6ff;
}

.receivables-table td strong,
.receivables-table td small {
    display: block;
}

.receivables-table td small {
    margin-top: 4px;
    color: #64748b;
}

.receivables-money {
    font-weight: 900;
    white-space: nowrap;
}

.receivables-money.positive {
    color: #166534;
}

.receivables-money.warning {
    color: #b45309;
}

.receivables-money.danger {
    color: #b91c1c;
}

.receivables-status {
    display: inline-flex;
    align-items: center;

    width: max-content;
    max-width: 190px;

    padding: 7px 10px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 900;
    line-height: 1.2;
    text-align: center;
}

.receivables-status.paid {
    background: #dcfce7;
    color: #166534;
}

.receivables-status.partial {
    background: #dbeafe;
    color: #1d4ed8;
}

.receivables-status.overdue {
    background: #fee2e2;
    color: #b91c1c;
}

.receivables-status.waiting {
    background: #fef3c7;
    color: #92400e;
}

.receivables-aging {
    display: inline-flex;

    padding: 6px 9px;

    border-radius: 999px;

    background: #e2e8f0;
    color: #334155;

    font-size: 11px;
    font-weight: 900;
}

.receivables-aging.danger {
    background: #fee2e2;
    color: #b91c1c;
}

.receivables-mobile-list {
    display: none;
}

.receivables-mobile-card {
    padding: 14px;

    border: 1px solid #e2e8f0;
    border-radius: 15px;

    background: #ffffff;

    box-shadow:
        0 7px 18px
        rgba(15, 23, 42, 0.06);
}

.receivables-mobile-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.receivables-mobile-card h3 {
    margin: 0 0 4px;
    color: #0f172a;
    font-size: 15px;
}

.receivables-mobile-card p {
    margin: 0;
    color: #64748b;
    font-size: 12px;
}

.receivables-mobile-card-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 8px;
    margin-top: 12px;
}

.receivables-mobile-card-grid div {
    padding: 9px;
    border-radius: 10px;
    background: #f8fafc;
}

.receivables-mobile-card-grid span,
.receivables-mobile-card-grid strong {
    display: block;
}

.receivables-mobile-card-grid span {
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.receivables-mobile-card-grid strong {
    margin-top: 4px;
    color: #0f172a;
    font-size: 13px;
}

.receivables-modal-box {
    width: min(1180px, 96vw);
    max-height: 94vh;

    padding: 0;
    gap: 0;

    overflow: hidden;
}

.receivables-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;

    padding: 18px 20px;

    background:
        linear-gradient(
            135deg,
            #0f172a,
            #1d4ed8
        );

    color: #ffffff;
}

.receivables-modal-header h2 {
    margin: 5px 0 0;
    color: #ffffff;
    font-size: 21px;
}

.receivables-modal-close {
    display: grid;
    place-items: center;

    width: 42px;
    height: 42px;

    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 12px;

    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;

    cursor: pointer;
}

.receivables-modal-scroll {
    min-height: 0;
    padding: 18px;
    overflow: auto;
    background: #f8fafc;
}

.receivables-details-summary {
    display: grid;
    grid-template-columns:
        repeat(6, minmax(0, 1fr));

    gap: 10px;
    margin-bottom: 14px;
}

.receivables-detail-metric {
    min-width: 0;
    padding: 12px;

    border: 1px solid #e2e8f0;
    border-radius: 13px;

    background: #ffffff;
}

.receivables-detail-metric span,
.receivables-detail-metric strong {
    display: block;
}

.receivables-detail-metric span {
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.receivables-detail-metric strong {
    margin-top: 5px;
    color: #0f172a;
    font-size: 15px;
    overflow-wrap: anywhere;
}

.receivables-details-columns {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 13px;
}

.receivables-detail-section {
    min-width: 0;
    margin-bottom: 13px;
    padding: 15px;

    border: 1px solid #e2e8f0;
    border-radius: 16px;

    background: #ffffff;
}

.receivables-detail-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;

    margin: 0 0 12px;

    color: #0f172a;
    font-size: 16px;
}

.receivables-form-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 10px;
}

.receivables-form-grid .full {
    grid-column: 1 / -1;
}

.receivables-form-grid label {
    display: grid;
    gap: 5px;

    color: #475569;

    font-size: 11px;
    font-weight: 900;
}

.receivables-form-grid input,
.receivables-form-grid select,
.receivables-form-grid textarea {
    width: 100%;
    min-width: 0;

    padding: 10px 11px;

    box-sizing: border-box;

    border: 1px solid #cbd5e1;
    border-radius: 10px;

    background: #ffffff;
}

.receivables-form-grid textarea {
    min-height: 82px;
    resize: vertical;
}

.receivables-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;

    margin-top: 11px;
}

.receivables-form-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    min-height: 40px;

    margin: 0;
    padding: 9px 13px;

    border: 0;
    border-radius: 10px;

    background: #2563eb;
    color: #ffffff;

    font-weight: 900;
    cursor: pointer;
}

.receivables-form-actions button.secondary {
    background: #e2e8f0;
    color: #334155;
}

.receivables-history-list {
    display: grid;
    gap: 8px;
}

.receivables-history-item {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        auto;

    gap: 12px;
    align-items: start;

    padding: 11px;

    border: 1px solid #e2e8f0;
    border-radius: 11px;

    background: #f8fafc;
}

.receivables-history-item strong,
.receivables-history-item small,
.receivables-history-item span {
    display: block;
}

.receivables-history-item small {
    margin-top: 3px;
    color: #64748b;
}

.receivables-history-item span {
    margin-top: 5px;
    color: #334155;
    font-size: 12px;
    line-height: 1.45;
}

.receivables-history-item button {
    width: 34px;
    height: 34px;

    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 9px;

    background: #fee2e2;
    color: #b91c1c;

    cursor: pointer;
}

.receivables-empty,
.receivables-loading,
.receivables-error {
    padding: 26px;
    text-align: center;
}

.receivables-empty,
.receivables-loading {
    color: #64748b;
}

.receivables-error {
    color: #b91c1c;
}

@media (max-width: 1350px) {

    .receivables-summary {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .receivables-filters {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .receivables-filters button {
        width: 100%;
    }

    .receivables-details-summary {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {

    .receivables-header {
        flex-direction: column;
        align-items: stretch;
    }

    .receivables-header-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .receivables-summary {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .receivables-filters {
        grid-template-columns: 1fr;
    }

    .receivables-table-wrap {
        display: none;
    }

    .receivables-mobile-list {
        display: grid;
        gap: 10px;
    }

    .receivables-details-columns {
        grid-template-columns: 1fr;
    }

    .receivables-details-summary {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .receivables-form-grid {
        grid-template-columns: 1fr;
    }

    .receivables-form-grid .full {
        grid-column: auto;
    }
}

/* CONNECTOR_STAGE_08_4_1_RECEIVABLES_UI_FIX_CSS_V1 */

/*
Główna tabela została skomasowana do siedmiu kolumn.
Na typowym ekranie nie powinna wymagać przewijania poziomego.
*/
.receivables-table {
    width: 100%;
    min-width: 980px;
    table-layout: fixed;
}

.receivables-table th,
.receivables-table td {
    padding: 10px 9px;
    vertical-align: top;
}

.receivables-table th:nth-child(1),
.receivables-table td:nth-child(1) {
    width: 17%;
}

.receivables-table th:nth-child(2),
.receivables-table td:nth-child(2) {
    width: 16%;
}

.receivables-table th:nth-child(3),
.receivables-table td:nth-child(3) {
    width: 19%;
}

.receivables-table th:nth-child(4),
.receivables-table td:nth-child(4) {
    width: 15%;
}

.receivables-table th:nth-child(5),
.receivables-table td:nth-child(5) {
    width: 15%;
}

.receivables-table th:nth-child(6),
.receivables-table td:nth-child(6) {
    width: 14%;
}

.receivables-table th:nth-child(7),
.receivables-table td:nth-child(7) {
    width: 4%;
}

.receivables-cell-lines {
    display: grid;
    gap: 4px;
}

.receivables-cell-lines strong {
    display: block;
    color: #0f172a;
}

.receivables-cell-lines small {
    display: block;
    margin: 0;
    color: #64748b;
    line-height: 1.35;
}

.receivables-cell-lines .danger {
    color: #b91c1c;
    font-weight: 900;
}

.receivables-cell-lines .positive {
    color: #166534;
    font-weight: 900;
}

.receivables-promise-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;

    width: max-content;
    max-width: 100%;

    padding: 5px 8px;
    margin-top: 4px;

    border-radius: 999px;

    background: #ede9fe;
    color: #6d28d9;

    font-size: 10px;
    font-weight: 900;
    line-height: 1.25;
}

.receivables-promise-badge.overdue {
    background: #fee2e2;
    color: #b91c1c;
}

/*
Modal jako kolumna flex.
Nagłówek pozostaje na miejscu, a środek przewija się pionowo.
*/
.receivables-modal-box {
    display: flex !important;
    flex-direction: column !important;

    width: min(1180px, 96vw);
    height: min(94vh, 1000px);
    max-height: 94vh;

    min-height: 0;
    overflow: hidden !important;
}

.receivables-modal-header {
    flex: 0 0 auto;
}

.receivables-modal-scroll {
    flex: 1 1 auto;
    min-height: 0;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.receivables-calendar-option {
    display: flex !important;
    grid-column: 1 / -1;

    flex-direction: row !important;
    align-items: center;
    gap: 9px;

    padding: 10px 12px;

    border: 1px solid #bfdbfe;
    border-radius: 11px;

    background: #eff6ff;
    color: #1e3a8a !important;

    cursor: pointer;
}

.receivables-calendar-option input {
    width: 18px !important;
    height: 18px !important;
    min-height: 0 !important;
    margin: 0;
    padding: 0;
}

.receivables-calendar-option span {
    font-size: 12px;
    font-weight: 900;
}

.receivables-filters-options {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;

    margin: 0 0 14px;
}

.receivables-filters-options label {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    margin: 0;

    color: #475569;
    font-size: 12px;
    font-weight: 900;
}

.receivables-filters-options input {
    width: 17px;
    height: 17px;
    margin: 0;
}

@media (max-width: 1100px) {

    .receivables-table {
        min-width: 900px;
    }

    .receivables-table th,
    .receivables-table td {
        padding: 9px 7px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {

    .receivables-modal-box {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .receivables-modal-scroll {
        padding-bottom:
            calc(
                24px
                +
                env(safe-area-inset-bottom)
            );
    }

    .receivables-filters-options {
        display: grid;
        gap: 10px;
    }
}

/* CONNECTOR_STAGE_08_4_2_RECEIVABLES_FILTERS_CSS_V1 */

.receivables-filters-options {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 10px;

    margin: 0 0 14px;
}

.receivables-switch-option {
    position: relative;

    display: inline-flex !important;
    align-items: center;
    gap: 11px;

    min-height: 48px;
    min-width: 235px;

    margin: 0 !important;
    padding: 8px 13px;

    box-sizing: border-box;

    border: 1px solid #dbe4f0;
    border-radius: 14px;

    background: #ffffff;
    color: #334155 !important;

    cursor: pointer;
    user-select: none;

    transition:
        border-color 0.16s ease,
        background 0.16s ease,
        box-shadow 0.16s ease,
        opacity 0.16s ease;
}

.receivables-switch-option:hover {
    border-color: #93c5fd;
    background: #f8fbff;

    box-shadow:
        0 5px 14px
        rgba(37, 99, 235, 0.08);
}

.receivables-switch-option:has(input:checked) {
    border-color: #60a5fa;
    background: #eff6ff;

    box-shadow:
        0 0 0 3px
        rgba(59, 130, 246, 0.10);
}

.receivables-switch-option:has(input:disabled) {
    opacity: 0.52;
    cursor: not-allowed;
}

.receivables-switch-option input {
    position: absolute;

    width: 1px !important;
    height: 1px !important;

    margin: 0 !important;
    padding: 0 !important;

    opacity: 0;
    pointer-events: none;
}

.receivables-switch {
    position: relative;

    flex: 0 0 auto;

    width: 40px;
    height: 23px;

    border-radius: 999px;

    background: #cbd5e1;

    box-shadow:
        inset 0 1px 2px
        rgba(15, 23, 42, 0.14);

    transition:
        background 0.18s ease;
}

.receivables-switch::after {
    content: "";

    position: absolute;
    top: 3px;
    left: 3px;

    width: 17px;
    height: 17px;

    border-radius: 50%;

    background: #ffffff;

    box-shadow:
        0 2px 6px
        rgba(15, 23, 42, 0.25);

    transition:
        transform 0.18s ease;
}

.receivables-switch-option
input:checked
+
.receivables-switch {
    background: #2563eb;
}

.receivables-switch-option
input:checked
+
.receivables-switch::after {
    transform: translateX(17px);
}

.receivables-switch-copy {
    display: grid;
    gap: 2px;

    min-width: 0;
}

.receivables-switch-copy strong {
    color: #0f172a;

    font-size: 12px;
    font-weight: 900;
    line-height: 1.2;
}

.receivables-switch-copy small {
    color: #64748b;

    font-size: 10px;
    font-weight: 700;
    line-height: 1.25;
}

.receivables-list-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 26px;
    height: 22px;

    margin-left: 7px;
    padding: 0 7px;

    border-radius: 999px;

    background: #dbeafe;
    color: #1d4ed8;

    font-size: 10px;
    font-weight: 900;
}

@media (max-width: 768px) {

    .receivables-filters-options {
        display: grid;
        grid-template-columns: 1fr;
    }

    .receivables-switch-option {
        width: 100%;
        min-width: 0;
    }
}

