/* ============================================================
   Sales Invoice UX
   Visual-only improvements for invoice register and invoice
   creation flow. Business rules and data contracts unchanged.
   ============================================================ */
.cg-invoice-page .cg-page-kicker {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .3rem;
    color: #2f6f61;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.cg-invoice-page h2 {
    color: #0d223c;
    font-weight: 700;
}

.cg-invoice-primary-action {
    min-width: 150px;
    padding: .65rem 1.05rem;
    font-weight: 700;
}

.cg-invoice-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 1.15rem;
    border: 1px solid #dfe7ef;
    border-radius: 14px;
    background: linear-gradient(135deg, #f5faf8 0%, #ffffff 72%);
    box-shadow: 0 5px 18px rgba(15, 35, 60, .05);
}

.cg-invoice-summary-main {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.cg-summary-icon,
.cg-ready-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e7f5ef;
    color: #087f5b;
    font-size: 1.15rem;
}

.cg-invoice-summary-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.cg-invoice-summary-stats > div {
    display: flex;
    flex-direction: column;
    min-width: 58px;
}

.cg-stat-value {
    font-size: 1.1rem;
    line-height: 1.15;
    font-weight: 800;
    color: #102a43;
}

.cg-stat-label {
    margin-top: .15rem;
    font-size: .7rem;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.cg-invoice-filter {
    border: 1px solid #dce4ec;
    border-radius: 12px;
}

.cg-invoice-filter .form-label {
    margin-bottom: .4rem;
    font-size: .8rem;
    font-weight: 700;
    color: #34495e;
}

.cg-invoice-filter .form-control,
.cg-invoice-filter .form-select {
    min-height: 42px;
}

.cg-filter-button {
    min-height: 42px;
}

.cg-invoice-list {
    border: 1px solid #dce4ec;
    border-radius: 12px;
    overflow: hidden;
}

.cg-invoice-list .card-header {
    padding: .9rem 1rem;
    background: #fff;
}

.cg-invoice-list .table thead th {
    white-space: nowrap;
    font-size: .78rem;
    text-transform: none;
    color: #34495e;
}

.cg-invoice-list .table tbody td {
    padding-top: .8rem;
    padding-bottom: .8rem;
}

.cg-invoice-list .table tbody tr:hover {
    background: #f8fbfd;
}

.cg-invoice-steps {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .9rem 1rem;
    border: 1px solid #dfe7ef;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 15px rgba(15, 35, 60, .04);
}

.cg-invoice-step {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
    color: #6b7b8c;
}

.cg-invoice-step.is-active {
    color: #102a43;
}

.cg-step-number {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid #cfd9e3;
    background: #f7f9fb;
    font-size: .78rem;
    font-weight: 800;
}

.cg-invoice-step.is-active .cg-step-number {
    border-color: #0b7f5f;
    background: #0b7f5f;
    color: #fff;
}

.cg-invoice-step strong,
.cg-invoice-step small {
    display: block;
}

.cg-invoice-step strong {
    font-size: .82rem;
}

.cg-invoice-step small {
    margin-top: .1rem;
    font-size: .7rem;
}

.cg-step-line {
    flex: 1 1 40px;
    height: 1px;
    min-width: 15px;
    background: #dbe3eb;
}

.cg-ready-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1.1rem;
    border: 1px solid #cfe9dc;
    border-radius: 12px;
    background: #f4fbf7;
}

.cg-ready-count {
    min-width: 42px;
    padding: .3rem .65rem;
    border-radius: 999px;
    background: #087f5b;
    color: #fff;
    text-align: center;
    font-weight: 800;
}

.cg-invoice-mobile-list {
    background: #f8fafc;
    padding: .65rem;
}

.cg-delivery-card {
    padding: 1rem;
    margin-bottom: .65rem;
    border: 1px solid #dfe6ed;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(15, 35, 60, .04);
}

.cg-delivery-card:last-child {
    margin-bottom: 0;
}

.cg-delivery-card-customer {
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.cg-delivery-card-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem;
    padding-top: .75rem;
    border-top: 1px solid #edf1f4;
}

@media (max-width: 767.98px) {
    .cg-invoice-page {
        padding-bottom: 1rem;
    }

    .cg-invoice-page .cg-page-kicker {
        font-size: .7rem;
    }

    .cg-invoice-page h2 {
        font-size: 1.45rem;
    }

    .cg-invoice-primary-action {
        width: 100%;
    }

    .cg-invoice-summary {
        align-items: stretch;
        flex-direction: column;
        gap: .85rem;
    }

    .cg-invoice-summary-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: .6rem;
        padding-top: .75rem;
        border-top: 1px solid #e4ebf0;
    }

    .cg-invoice-summary-stats > div {
        min-width: 0;
    }

    .cg-invoice-summary-stats > div:nth-child(4) {
        display: none;
    }

    .cg-invoice-steps {
        overflow-x: auto;
        align-items: flex-start;
        padding: .75rem;
    }

    .cg-invoice-step {
        flex: 0 0 auto;
    }

    .cg-invoice-step small {
        white-space: nowrap;
    }

    .cg-step-line {
        flex: 0 0 22px;
        margin-top: 14px;
    }

    .cg-ready-banner {
        align-items: center;
    }

    .cg-invoice-list .card-header {
        padding: .8rem;
    }
}

@media (max-width: 575.98px) {
    .cg-invoice-page h2 {
        font-size: 1.3rem;
    }

    .cg-ready-banner {
        padding: .8rem;
    }

    .cg-ready-icon {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .cg-delivery-card-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .cg-delivery-card-footer .btn {
        width: 100%;
    }
}

/* ============================================================
   Invoice editor / review UX
   ============================================================ */
.cg-invoice-editor {
    padding-bottom: 1.25rem;
}

.cg-editor-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.cg-editor-header-actions {
    display: flex;
    gap: .6rem;
    flex: 0 0 auto;
}

.cg-source-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border: 1px solid #d6e6df;
    border-radius: 14px;
    background: linear-gradient(135deg, #f2faf6 0%, #ffffff 75%);
    box-shadow: 0 4px 14px rgba(15, 35, 60, .04);
}

.cg-source-icon {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: #e4f4ed;
    color: #087f5b;
    font-size: 1.2rem;
}

.cg-source-customer {
    min-width: 230px;
    padding-left: 1rem;
    border-left: 1px solid #dbe7e1;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.cg-editor-card {
    border: 1px solid #dce4ec;
    border-radius: 12px;
    overflow: hidden;
}

.cg-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #fff;
    padding: .9rem 1rem;
}

.cg-field-label {
    font-size: .8rem;
    font-weight: 700;
    color: #34495e;
}

.cg-readonly-field {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .55rem .75rem;
    border: 1px solid #e0e6ec;
    border-radius: .375rem;
    background: #f7f9fb;
    color: #243b53;
}

.cg-readonly-field i {
    color: #087f5b;
}

.cg-total-card {
    border: 1px solid #d7e7df;
    border-radius: 12px;
    background: linear-gradient(145deg, #f3faf7 0%, #ffffff 80%);
}

.cg-preview-label {
    margin-top: .7rem;
    color: #52667a;
    font-size: .82rem;
}

.cg-preview-total {
    margin: .1rem 0 .15rem;
    color: #0b3d2e;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.15;
}

.cg-total-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .45rem 0;
    color: #52667a;
}

.cg-total-row strong {
    color: #102a43;
}

.cg-invoice-lines-mobile {
    display: none;
}

.cg-invoice-lines-desktop .table thead th {
    white-space: nowrap;
    font-size: .75rem;
    color: #34495e;
}

.cg-invoice-lines-desktop .table tbody td {
    padding-top: .75rem;
    padding-bottom: .75rem;
}

.cg-qty-input {
    min-height: 42px;
    font-weight: 700;
}

.cg-line-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .65rem;
    margin: .9rem 0;
    padding: .75rem 0;
    border-top: 1px solid #edf1f4;
    border-bottom: 1px solid #edf1f4;
}

.cg-line-meta-grid div {
    display: flex;
    flex-direction: column;
    gap: .12rem;
}

.cg-line-meta-grid span {
    color: #718096;
    font-size: .72rem;
}

.cg-line-meta-grid strong {
    color: #243b53;
    font-size: .82rem;
}

.cg-mobile-qty-row {
    display: grid;
    grid-template-columns: 1fr 130px;
    align-items: center;
    gap: .75rem;
}

.cg-invoice-line-card {
    padding: 1rem;
    margin-bottom: .65rem;
    border: 1px solid #dfe6ed;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(15, 35, 60, .04);
}

.cg-invoice-line-card:last-child {
    margin-bottom: 0;
}

.cg-editor-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1rem;
    border: 1px solid #dce4ec;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 35, 60, .04);
}

.cg-invoice-editor .cg-invoice-step.is-complete {
    color: #087f5b;
}

.cg-invoice-editor .cg-invoice-step.is-complete .cg-step-number {
    border-color: #087f5b;
    background: #e7f5ef;
    color: #087f5b;
}

@media (max-width: 991.98px) {
    .cg-editor-header {
        align-items: stretch;
        flex-direction: column;
    }

    .cg-editor-header-actions {
        width: 100%;
    }

    .cg-editor-header-actions .btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 767.98px) {
    .cg-source-banner {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .cg-source-customer {
        width: 100%;
        min-width: 0;
        padding-left: 0;
        padding-top: .75rem;
        border-left: 0;
        border-top: 1px solid #dbe7e1;
    }

    .cg-invoice-lines-desktop {
        display: none;
    }

    .cg-invoice-lines-mobile {
        display: block;
        padding: .65rem;
        background: #f8fafc;
    }

    .cg-editor-bottom-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .cg-editor-bottom-bar > div:last-child {
        display: grid !important;
        grid-template-columns: 1fr 1.3fr;
    }

    .cg-editor-bottom-bar .btn {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .cg-editor-header-actions {
        display: grid;
        grid-template-columns: 1fr 1.2fr;
    }

    .cg-source-banner {
        padding: .85rem;
    }

    .cg-source-icon {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .cg-preview-total {
        font-size: 1.7rem;
    }
}
