/* Billing ERP — Admin UI enhancements */

:root {
    --billing-radius: 0.5rem;
    --billing-radius-lg: 0.75rem;
    --billing-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
    --billing-shadow-hover: 0 4px 20px rgba(15, 23, 42, 0.08);
    --billing-border: #e9ebec;
    --billing-muted: #878a99;
    --billing-sale: #0ab39c;
    --billing-sale-bg: rgba(10, 179, 156, 0.08);
    --billing-purchase: #405189;
    --billing-purchase-bg: rgba(64, 81, 137, 0.08);
    --billing-product: #3577f1;
    --billing-service: #f7b84b;
}

/* Page & cards */
.billing-page-card {
    border: 1px solid var(--billing-border);
    border-radius: var(--billing-radius-lg);
    box-shadow: var(--billing-shadow);
    overflow: hidden;
}

.billing-page-card .card-header {
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
    border-bottom: 1px solid var(--billing-border);
    padding: 1rem 1.25rem;
}

.billing-page-card .card-body {
    padding: 1.25rem;
}

.billing-form-card {
    border: 1px solid var(--billing-border);
    border-radius: var(--billing-radius-lg);
    box-shadow: var(--billing-shadow);
    background: #fff;
}

.billing-form-card .card-body {
    padding: 1.5rem 1.75rem;
}

/* Section blocks */
.billing-section {
    margin-bottom: 1.5rem;
}

.billing-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--billing-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--billing-border);
}

.billing-section-title i {
    font-size: 1rem;
    opacity: 0.85;
}

/* Type toggle (Product / Service) */
.billing-type-toggle {
    display: inline-flex;
    padding: 4px;
    background: #f3f6f9;
    border-radius: 0.5rem;
    border: 1px solid var(--billing-border);
    gap: 2px;
}

.billing-type-toggle .nav-link {
    border: none !important;
    border-radius: 0.375rem !important;
    padding: 0.5rem 1.25rem !important;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--billing-muted) !important;
    background: transparent !important;
    transition: all 0.2s ease;
}

.billing-type-toggle .nav-link:hover:not(.active) {
    color: #495057 !important;
    background: rgba(255, 255, 255, 0.6) !important;
}

.billing-type-toggle .nav-link.active[data-type="product"] {
    background: var(--billing-product) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(53, 119, 241, 0.35);
}

.billing-type-toggle .nav-link.active[data-type="service"] {
    background: var(--billing-service) !important;
    color: #1a1d21 !important;
    box-shadow: 0 2px 8px rgba(247, 184, 75, 0.4);
}

/* Pricing panels */
.billing-price-panel {
    border-radius: var(--billing-radius-lg);
    padding: 1.25rem;
    height: 100%;
    border: 1px solid var(--billing-border);
    transition: box-shadow 0.2s ease;
}

.billing-price-panel:hover {
    box-shadow: var(--billing-shadow-hover);
}

.billing-price-panel--sale {
    background: var(--billing-sale-bg);
    border-color: rgba(10, 179, 156, 0.2);
}

.billing-price-panel--sale .billing-price-panel__head {
    color: var(--billing-sale);
}

.billing-price-panel--purchase {
    background: var(--billing-purchase-bg);
    border-color: rgba(64, 81, 137, 0.15);
}

.billing-price-panel--purchase .billing-price-panel__head {
    color: var(--billing-purchase);
}

.billing-price-panel__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.billing-price-panel__head i {
    font-size: 1.1rem;
}

/* Form fields */
.billing-form-card .form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.35rem;
}

.billing-form-card .form-control,
.billing-form-card .form-select {
    border-radius: var(--billing-radius);
    border-color: var(--billing-border);
    font-size: 0.875rem;
}

.billing-form-card .form-control:focus,
.billing-form-card .form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.15rem rgba(53, 119, 241, 0.12);
}

.billing-input-icon {
    position: relative;
}

.billing-input-icon .form-control,
.billing-input-icon .form-select {
    padding-left: 2.25rem;
}

.billing-input-icon > i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--billing-muted);
    font-size: 1rem;
    z-index: 4;
    pointer-events: none;
}

.billing-input-icon--readonly .form-control {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

/* Description counter */
.billing-char-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--billing-muted);
}

.billing-char-bar {
    flex: 1;
    max-width: 120px;
    height: 4px;
    background: #e9ebec;
    border-radius: 2px;
    margin-right: 0.75rem;
    overflow: hidden;
}

.billing-char-bar__fill {
    height: 100%;
    background: var(--billing-product);
    border-radius: 2px;
    transition: width 0.2s ease, background 0.2s ease;
}

.billing-char-bar__fill.is-warning {
    background: var(--billing-service);
}

.billing-char-bar__fill.is-danger {
    background: #f06548;
}

/* Meta row (HSN, SKU, qty) */
.billing-meta-grid .form-label {
    font-size: 0.75rem;
}

/* Sticky form footer */
.billing-form-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--billing-border);
    border-radius: var(--billing-radius-lg);
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.billing-form-footer .btn-success {
    min-width: 120px;
}

/* List / index tables */
.billing-table-wrap {
    border-radius: var(--billing-radius);
    overflow: hidden;
}

.billing-table-wrap .table {
    margin-bottom: 0;
}

.billing-table-wrap .table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--billing-muted);
    background: #f8f9fa !important;
    border-bottom-width: 1px;
    white-space: nowrap;
    padding: 0.75rem 1rem;
}

.billing-table-wrap .table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
}

.billing-table-wrap .table tbody tr:hover {
    background-color: rgba(53, 119, 241, 0.03);
}

.billing-item-name {
    font-weight: 500;
    color: #212529;
}

.billing-item-sub {
    font-size: 0.75rem;
    color: var(--billing-muted);
}

.billing-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.billing-avatar-sm--product {
    background: rgba(53, 119, 241, 0.12);
    color: var(--billing-product);
}

.billing-avatar-sm--service {
    background: rgba(247, 184, 75, 0.2);
    color: #b8860b;
}

/* Empty state */
.billing-empty {
    text-align: center;
    padding: 3rem 1.5rem;
}

.billing-empty__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #f3f6f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--billing-muted);
}

/* Alerts */
.billing-alert {
    border-radius: var(--billing-radius-lg);
    border: none;
    box-shadow: var(--billing-shadow);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
}

.billing-alert .alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.billing-alert-success {
    background: rgba(10, 179, 156, 0.1);
    color: #0a8f7c;
}

.billing-alert-danger {
    background: rgba(240, 101, 72, 0.1);
    color: #c94a32;
}

/* Search bar on list pages */
.billing-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.billing-search {
    max-width: 280px;
    position: relative;
}

.billing-search .form-control {
    padding-left: 2.25rem;
    border-radius: 2rem;
    font-size: 0.875rem;
}

.billing-search i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--billing-muted);
}

/* Two-column entity forms (customer/vendor) */
.billing-entity-form .card {
    border-radius: var(--billing-radius-lg);
    box-shadow: var(--billing-shadow);
    border-color: var(--billing-border);
}

.billing-entity-form .nav-tabs-custom .nav-link {
    font-size: 0.8125rem;
    font-weight: 500;
}

.billing-entity-form .nav-tabs-custom .nav-link.active {
    font-weight: 600;
}

/* Invoice listing page */
.billing-invoice-toolbar .card-body {
    padding: 0.85rem 1.25rem;
}

.billing-invoice-quick-search {
    position: relative;
}

.billing-invoice-quick-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--billing-muted);
    z-index: 2;
}

.billing-invoice-quick-search .form-control {
    padding-left: 2.5rem;
    border-radius: 2rem;
    border-color: var(--billing-border);
}

.billing-invoice-filters {
    background: #fafbfc;
}

.billing-invoice-filters .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--billing-muted);
    margin-bottom: 0.25rem;
}

.billing-invoice-new-menu {
    min-width: 280px;
    padding: 0.35rem;
}

.billing-invoice-new-menu .dropdown-item {
    border-radius: 0.375rem;
    white-space: normal;
}

.billing-invoice-new-menu .dropdown-item small {
    display: block;
    font-size: 0.7rem;
    margin-top: 2px;
}

.billing-invoice-table thead th {
    font-size: 0.7rem;
    white-space: nowrap;
}

.billing-invoice-empty h4 {
    color: #405189;
}

.letter-spacing-1 {
    letter-spacing: 0.08em;
}

/* Invoice lifecycle */
.billing-invoice-lifecycle {
    padding: 1.5rem 1rem;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    border-radius: var(--billing-radius-lg);
    border: 1px dashed var(--billing-border);
}

.lifecycle-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 0.5rem 0.25rem;
}

.lifecycle-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    min-width: 72px;
}

.lifecycle-step span {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--billing-muted);
    text-transform: uppercase;
}

.lifecycle-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px dashed var(--billing-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: #fff;
}

.lifecycle-icon--draft { color: #3577f1; border-color: rgba(53, 119, 241, 0.35); }
.lifecycle-icon--sent { color: #3577f1; border-color: rgba(53, 119, 241, 0.35); }
.lifecycle-icon--unpaid { color: #f06548; border-color: rgba(240, 101, 72, 0.35); }
.lifecycle-icon--overdue { color: #f7b84b; border-color: rgba(247, 184, 75, 0.5); }
.lifecycle-icon--partial { color: #299cdb; border-color: rgba(41, 156, 219, 0.35); }
.lifecycle-icon--paid { color: #0ab39c; border-color: rgba(10, 179, 156, 0.35); }
.lifecycle-icon--cancel { color: #f06548; border-color: rgba(240, 101, 72, 0.35); }
.lifecycle-icon--delete { color: #f06548; border-color: rgba(240, 101, 72, 0.35); }

.lifecycle-step--sm .lifecycle-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.lifecycle-arrow {
    color: #ced4da;
    font-size: 1.25rem;
    padding-top: 0.75rem;
}

.lifecycle-branch {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-left: 0.5rem;
    padding-left: 1rem;
    border-left: 2px dashed #e9ebec;
}

.lifecycle-branch-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.billing-invoice-features {
    max-width: 640px;
    margin: 0 auto;
}

/* Quote lifecycle */
.billing-quote-lifecycle .lifecycle-flow--quote {
    max-width: 720px;
    margin: 0 auto;
}

.lifecycle-icon--invoice {
    color: #3577f1;
    border-color: rgba(53, 119, 241, 0.35);
}

.lifecycle-branch--quote {
    margin-top: 0.25rem;
}

.lifecycle-loop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    color: #adb5bd;
    font-size: 1.1rem;
    padding-top: 0.5rem;
    margin-left: 0.5rem;
}

.lifecycle-loop-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--billing-muted);
}

.billing-quotes-page .billing-invoice-features {
    max-width: 100%;
}

/* Invoice create form */
/* Line items table column layout */
.billing-line-items-table .col-no { width: 36px; }
.billing-line-items-table .col-item { width: 130px; min-width: 120px; }
.billing-line-items-table .col-desc {
    width: 22%;
    min-width: 200px;
    max-width: 320px;
}
.billing-line-items-table .col-unit { width: 92px; min-width: 86px; max-width: 110px; }
.billing-line-items-table .col-qty { width: 62px; }
.billing-line-items-table .col-price { width: 78px; }
.billing-line-items-table .col-disc { width: 62px; }
.billing-line-items-table .col-tax { width: 96px; min-width: 88px; }
.billing-line-items-table .col-total { width: 88px; }
.billing-line-items-table .col-act { width: 40px; }

.billing-line-items-table--gst .col-hsn {
    width: 58px;
    min-width: 52px;
    max-width: 68px;
}
.billing-line-items-table--gst .col-gst-rate {
    width: 78px;
    min-width: 72px;
    max-width: 92px;
}
.billing-line-items-table--gst .col-cgst,
.billing-line-items-table--gst .col-sgst,
.billing-line-items-table--gst .col-igst {
    width: 50px;
    min-width: 46px;
    max-width: 58px;
}

.billing-invoice-form .billing-line-items-table thead th {
    font-size: 0.68rem;
    white-space: nowrap;
    vertical-align: middle;
    padding: 0.5rem 0.35rem;
}

.billing-invoice-form .billing-line-items-table td {
    vertical-align: top;
    font-size: 0.8125rem;
    padding: 0.4rem 0.35rem;
}

.billing-desc-field {
    min-height: 56px;
    min-width: 100%;
    font-size: 0.75rem !important;
    resize: vertical;
}

.billing-line-items-table--gst .col-desc {
    min-width: 180px;
}

.billing-line-items-table--gst .col-hsn input,
.billing-line-items-table--gst .col-gst-rate select,
.billing-line-items-table--gst .col-cgst input,
.billing-line-items-table--gst .col-sgst input,
.billing-line-items-table--gst .col-igst input {
    font-size: 0.72rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.billing-desc-hint {
    font-size: 0.65rem;
    display: block;
    text-align: right;
    margin-top: 2px;
}

/* Searchable unit picker */
.billing-unit-picker {
    position: relative;
    min-width: 140px;
}

.billing-line-items-table .col-unit .billing-unit-picker {
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.billing-unit-picker__trigger {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 31px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    background: #fff;
}

.billing-unit-picker__label {
    flex: 1;
    font-size: 0.75rem;
    max-width: calc(100% - 18px);
}

.billing-unit-picker__arrow {
    flex-shrink: 0;
    color: var(--billing-muted);
}

.billing-unit-picker__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    margin-top: 2px;
    background: #fff;
    border: 1px solid #86b7fe;
    border-radius: var(--billing-radius);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    min-width: 220px;
}

.billing-unit-picker__search-wrap {
    padding: 0.4rem;
    border-bottom: 1px solid var(--billing-border);
}

.billing-unit-picker__search {
    font-size: 0.8rem;
}

.billing-unit-picker__list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

.billing-unit-picker__option {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
}

.billing-unit-picker__option:hover,
.billing-unit-picker__option:focus {
    background: #e8f4fd;
    outline: none;
}

.billing-unit-picker__option.is-gst strong {
    font-weight: 600;
}

.billing-unit-picker__add {
    border-top: 1px solid var(--billing-border);
    padding: 0.45rem 0.65rem !important;
    color: var(--billing-product) !important;
    text-decoration: none !important;
}

.billing-unit-picker__add:hover {
    background: #f8f9fa;
}

.billing-unit-picker--lg .billing-unit-picker__trigger {
    min-height: calc(1.5em + 0.75rem + 2px);
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

.billing-unit-picker--lg .billing-unit-picker__label {
    font-size: 0.875rem;
}

/* Searchable client picker */
.billing-client-picker__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.billing-client-picker__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.billing-client-picker__edit {
    flex-shrink: 0;
    color: var(--billing-muted);
    padding: 0 0.25rem;
    line-height: 1;
}

.billing-client-picker__edit:hover {
    color: var(--billing-product);
}

.billing-client-picker__add {
    font-weight: 500;
}

.billing-unit-modal__header {
    background: var(--billing-product, #0ab39c);
    color: #fff;
    border: 0;
    padding: 0.85rem 1rem;
}

.billing-unit-modal__header .modal-title {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Quick add client modal — scrollable body, fixed footer */
.billing-quick-client-dialog {
    max-width: 520px;
    margin: 1rem auto;
}

.billing-quick-client-modal__header {
    background: #fff;
    border-bottom: 1px solid #e8edf2;
    padding: 1rem 1.15rem 0.9rem;
    align-items: flex-start;
    gap: 0.5rem;
}

.billing-quick-client-modal__header-main {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.billing-quick-client-modal__header-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(145deg, #e8f8f5 0%, #d4f1eb 100%);
    color: var(--billing-product, #0ab39c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: inset 0 0 0 1px rgba(10, 179, 156, 0.12);
}

.billing-quick-client-modal__header-text {
    min-width: 0;
    padding-top: 0.1rem;
}

.billing-quick-client-modal__header .modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b !important;
    line-height: 1.3;
    margin: 0;
}

.billing-quick-client-modal__subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.78rem;
    line-height: 1.35;
    color: #64748b;
}

.billing-quick-client-modal__header .btn-close {
    margin: 0.15rem 0 0 auto;
    padding: 0.5rem;
    opacity: 0.55;
}

.billing-quick-client-modal__header .btn-close:hover {
    opacity: 0.9;
}

.billing-quick-client-modal {
    max-height: min(92vh, 720px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--billing-radius, 0.5rem);
    border: 0;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
}

.billing-quick-client-modal::before {
    content: '';
    display: block;
    height: 3px;
    background: linear-gradient(90deg, var(--billing-product, #0ab39c), #38c9b1);
    flex-shrink: 0;
}

.billing-quick-client-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.billing-quick-client-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 1.15rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(10, 179, 156, 0.45) transparent;
}

.billing-quick-client-modal__body::-webkit-scrollbar {
    width: 6px;
}

.billing-quick-client-modal__body::-webkit-scrollbar-thumb {
    background: rgba(10, 179, 156, 0.4);
    border-radius: 4px;
}

.billing-quick-client-modal__footer {
    border-top: 1px solid var(--billing-border, #e9ecef);
    background: #fff;
    padding: 0.65rem 1.15rem;
    box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.06);
    z-index: 2;
}

.billing-quick-client-section {
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
}

.billing-quick-client-section:last-of-type {
    border-bottom: 0;
    margin-bottom: 0.5rem;
    padding-bottom: 0;
}

.billing-quick-client-section__title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.billing-quick-client-section__title i {
    color: var(--billing-product, #0ab39c);
    font-size: 1rem;
}

.billing-quick-client-accordion {
    --bs-accordion-border-width: 0;
    --bs-accordion-btn-padding-x: 0.65rem;
    --bs-accordion-btn-padding-y: 0.55rem;
    --bs-accordion-body-padding-x: 0.65rem;
    --bs-accordion-body-padding-y: 0.65rem;
}

.billing-quick-client-accordion .accordion-item {
    border: 1px solid #eef1f5;
    border-radius: 0.4rem !important;
    margin-bottom: 0.45rem;
    overflow: hidden;
}

.billing-quick-client-accordion .accordion-button {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    box-shadow: none !important;
}

.billing-quick-client-accordion .accordion-button:not(.collapsed) {
    color: var(--billing-product, #0ab39c);
    background: #f0fdf9;
}

.billing-quick-client-accordion .accordion-button::after {
    width: 0.85rem;
    height: 0.85rem;
    background-size: 0.85rem;
}

.billing-quick-client-modal .form-label-sm {
    font-size: 0.72rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
    color: #64748b;
}

.billing-advance-modal__header {
    background: var(--billing-product, #0ab39c);
    color: #fff;
    border: 0;
    padding: 0.85rem 1rem;
}

.billing-advance-modal__header .modal-title {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Invoice additional options */
.billing-invoice-options-row {
    margin-top: 0.5rem;
}

.billing-options-heading {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--billing-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--billing-border);
}

.billing-option-block {
    border: 1px solid var(--billing-border);
    border-radius: var(--billing-radius);
    margin-bottom: 0.65rem;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.billing-option-block.is-active {
    border-color: rgba(10, 179, 156, 0.45);
    box-shadow: 0 0 0 1px rgba(10, 179, 156, 0.08);
}

.billing-option-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: #fafbfc;
    border-radius: var(--billing-radius) var(--billing-radius) 0 0;
}

.billing-option-block:not(.is-active) .billing-option-head {
    border-radius: var(--billing-radius);
}

.billing-option-head .form-check-input:checked {
    background-color: var(--billing-sale);
    border-color: var(--billing-sale);
}

.billing-option-body {
    padding: 0.65rem 0.85rem 0.75rem;
    border-top: 1px solid var(--billing-border);
}

.billing-option-hint {
    font-size: 0.7rem;
    color: #b8860b;
    line-height: 1.35;
}

.billing-option-inline-val {
    margin-left: auto;
}

/* Invoice amount summary (right panel) */
.billing-invoice-summary {
    background: #fff;
    border: 1px solid var(--billing-border) !important;
    overflow: hidden;
}

.billing-summary-header {
    background: linear-gradient(180deg, #f3f6f9 0%, #eef1f4 100%);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--billing-muted);
    border-bottom: 1px solid var(--billing-border);
}

.billing-summary-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0;
    font-size: 0.875rem;
    border-bottom: 1px dashed #f0f1f3;
}

.billing-summary-line:last-child {
    border-bottom: none;
}

.billing-summary-line--deduct span:first-child {
    color: var(--billing-muted);
}

.billing-summary-tax-breakdown .billing-summary-line--tax span:first-child {
    color: var(--billing-body);
    font-weight: 500;
}

.billing-summary-tax-breakdown .billing-summary-line--tax span:last-child {
    color: var(--billing-body);
}

.billing-summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 179, 156, 0.1);
    border-top: 2px solid rgba(10, 179, 156, 0.25);
}

.billing-summary-total__amount {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--billing-sale);
}

.billing-invoice-header-grid .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--billing-muted);
}

@media (max-width: 991.98px) {
    .lifecycle-flow {
        flex-direction: column;
        align-items: center;
    }

    .lifecycle-branch {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
    }

    .billing-invoice-table {
        font-size: 0.8rem;
    }
}

/* Responsive */
@media (max-width: 767.98px) {
    .billing-form-card .card-body {
        padding: 1rem;
    }

    .billing-form-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .billing-form-footer .btn {
        width: 100%;
    }

    .billing-type-toggle {
        width: 100%;
        justify-content: stretch;
    }

    .billing-type-toggle .nav-link {
        flex: 1;
        text-align: center;
    }
}

/* Clients / Customers */
.billing-clients-table thead th {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    vertical-align: middle;
    border-bottom-width: 1px;
}

.billing-client-link {
    color: #405189;
    text-decoration: none;
    font-weight: 500;
}

.billing-client-link:hover {
    color: #354372;
    text-decoration: underline;
}

.billing-clients-split {
    min-height: calc(100vh - 220px);
    border: 1px solid var(--billing-border);
    border-radius: var(--billing-radius-lg);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--billing-shadow);
}

.billing-clients-sidebar {
    border-right: 1px solid var(--billing-border);
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
}

.billing-clients-sidebar__toolbar {
    display: flex;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--billing-border);
    background: #fff;
    align-items: stretch;
}

.btn-filter-clients {
    background: #fff;
    border: 1px solid #c9cdd3;
    color: #495057;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.45rem 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    border-radius: 0.35rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-filter-clients:hover,
.btn-filter-clients:focus {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
}

.btn-filter-clients::after {
    margin-left: auto;
}

.billing-filter-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #0ab39c;
    flex-shrink: 0;
}

.btn-new-client {
    background: #405189;
    border: none;
    color: #fff;
    padding: 0.45rem 0.7rem;
    border-radius: 0.35rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(64, 81, 137, 0.25);
}

.btn-new-client:hover {
    background: #354372;
    color: #fff;
}

.btn-sort-menu {
    background: #fff;
    border: 1px solid #c9cdd3;
    color: #495057;
    padding: 0.45rem 0.55rem;
    border-radius: 0.35rem;
    line-height: 1;
}

.btn-sort-menu:hover {
    background: #f3f6f9;
    border-color: #adb5bd;
}

.billing-sort-dropdown {
    min-width: 200px;
    border-radius: 0.5rem;
    border: 1px solid var(--billing-border);
    overflow: hidden;
}

.billing-sort-menu__title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--billing-muted);
    padding: 0.65rem 1rem 0.35rem;
}

.billing-sort-menu__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 1rem;
    color: #495057;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.12s ease;
}

.billing-sort-menu__item:hover {
    background: #f3f6f9;
    color: #212529;
}

.billing-sort-menu__item.is-active {
    background: #e9ecef;
    color: #212529;
    font-weight: 600;
}

.billing-sort-menu__divider {
    height: 1px;
    background: var(--billing-border);
    margin: 0.25rem 0;
}

.billing-sidebar-search {
    position: relative;
}

.billing-sidebar-search i {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--billing-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.billing-sidebar-search .form-control {
    padding-left: 2rem;
    border-radius: 0.35rem;
    background: #fff;
}

.billing-clients-filter-menu {
    border-radius: 0.5rem !important;
}

.billing-th-sort {
    color: #495057;
    font-weight: 600;
    font-size: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.billing-th-sort:hover {
    color: #405189;
}

.billing-th-sort.is-active {
    color: #495057;
    font-weight: 600;
}

.billing-th-sort i {
    font-size: 0.75rem;
    color: var(--billing-muted);
    font-weight: normal;
}

.billing-clients-sidebar__list {
    overflow-y: auto;
    flex: 1;
}

.billing-client-list-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--billing-border);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.billing-client-list-item:hover {
    background: rgba(10, 179, 156, 0.06);
}

.billing-client-list-item.is-active {
    background: rgba(10, 179, 156, 0.12);
    border-left: 3px solid var(--billing-sale);
}

.billing-client-list-item__avatar--vendor,
.billing-client-detail__icon--vendor {
    background: var(--billing-purchase-bg);
    color: var(--billing-purchase);
}

.billing-client-list-item__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--billing-sale-bg);
    color: var(--billing-sale);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.billing-client-list-item__content {
    flex: 1;
    min-width: 0;
}

.billing-client-list-item__name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.billing-client-list-item__sub {
    font-size: 0.72rem;
    color: var(--billing-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.billing-client-list-item__balance {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--billing-muted);
    flex-shrink: 0;
    text-align: right;
}

.btn-panel-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #495057;
    background: #fff;
    border: 1px solid #d7dce3;
    border-radius: 0.35rem;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-panel-action:hover,
.btn-panel-action:focus {
    background: #f8f9fa;
    border-color: #c9cdd3;
    color: #212529;
}

.btn-panel-action i {
    font-size: 1rem;
}

.btn-panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: #878a99;
    border-radius: 0.35rem;
    text-decoration: none;
}

.btn-panel-close:hover {
    background: #f3f6f9;
    color: #212529;
}

.billing-clients-panel {
    display: flex;
    flex-direction: column;
    min-height: 480px;
}

.billing-clients-panel__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--billing-border);
    background: #fff;
}

.billing-clients-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
    background: #f8f9fb;
}

.billing-client-detail__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.billing-client-detail.card {
    border-radius: var(--billing-radius-lg);
}

.billing-client-detail__icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(10, 179, 156, 0.15) 0%, rgba(53, 119, 241, 0.12) 100%);
    color: var(--billing-sale);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.billing-client-detail__meta li {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.35rem 0;
    font-size: 0.9rem;
}

.billing-client-detail__meta .label {
    min-width: 110px;
    color: var(--billing-muted);
    font-size: 0.8rem;
}

.billing-client-detail__divider {
    margin: 1.25rem 0;
    border-color: var(--billing-border);
}

.billing-client-detail__section-title {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--billing-muted);
    margin-bottom: 0.75rem;
}

.billing-client-detail__address address {
    font-size: 0.9rem;
    color: #495057;
    font-style: normal;
    line-height: 1.6;
}

/* Statement document */
.billing-statement-doc {
    background: #fff;
    border: 1px solid var(--billing-border);
    border-radius: var(--billing-radius-lg);
    padding: 2rem;
    box-shadow: var(--billing-shadow);
}

.billing-statement-summary {
    border: 1px solid var(--billing-border);
    border-radius: var(--billing-radius);
    overflow: hidden;
}

.billing-statement-summary__head {
    background: #405189;
    color: #fff;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
}

.billing-statement-summary__row {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--billing-border);
}

.billing-statement-summary__row--total {
    font-weight: 700;
    background: #f3f6f9;
    border-bottom: none;
}

.billing-statement-table thead th {
    background: #405189;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.billing-statement-filter-menu {
    border-radius: var(--billing-radius-lg);
}

@media print {
    .billing-clients-sidebar,
    .billing-clients-panel__toolbar,
    .page-title-box,
    #layout-wrapper .app-menu,
    .navbar-header,
    .footer {
        display: none !important;
    }

    .billing-clients-panel__body {
        padding: 0;
        background: #fff;
    }

    .billing-statement-doc {
        border: none;
        box-shadow: none;
    }

    .main-content {
        margin: 0 !important;
    }
}
