/*
 * Fast Invoices - Tabler/Bootstrap 5 custom overrides
 * Layout: Horizontal top navbar (Tabler default)
 */

/* Azure colour scheme */
:root {
    --tblr-primary: #45aaf2;
    --tblr-primary-rgb: 69, 170, 242;
    --tblr-azure: #45aaf2;
    --tblr-azure-rgb: 69, 170, 242;
    --tblr-link-color: #45aaf2;
}

/* Light grey outline buttons - match Tabler preview slate style */
.btn-outline-secondary {
    --tblr-btn-color: var(--tblr-body-color);
    --tblr-btn-border-color: var(--tblr-border-color);
    --tblr-btn-hover-color: var(--tblr-body-color);
    --tblr-btn-hover-bg: var(--tblr-bg-surface-secondary);
    --tblr-btn-hover-border-color: var(--tblr-border-color);
    --tblr-btn-active-color: var(--tblr-body-color);
    --tblr-btn-active-bg: var(--tblr-bg-surface-secondary);
    --tblr-btn-active-border-color: var(--tblr-border-color);
}

/* Top navbar brand */
.navbar-brand {
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}
.navbar-brand i.ti {
    vertical-align: middle;
}

@media (min-width: 992px) {
    #navbar-menu > .navbar > .container-xl {
        flex-wrap: wrap;
    }
}

/* On compact screens, keep navigation over the page instead of in its flow. */
@media (max-width: 991.98px) {
    body.si-mobile-nav-open {
        overflow: hidden;
    }

    body.si-mobile-nav-open > .page > header.navbar-expand-lg.sticky-top {
        z-index: 1060;
    }

    .si-mobile-nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1050;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        background: rgba(24, 36, 51, 0.48);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    body.si-mobile-nav-open .si-mobile-nav-backdrop {
        opacity: 1;
        visibility: visible;
    }

    #navbar-menu {
        position: fixed;
        inset: 3.75rem auto 0 0;
        z-index: 1061;
        display: block !important;
        width: min(22rem, calc(100vw - 3rem));
        height: auto !important;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--tblr-bg-surface, #fff);
        box-shadow: var(--tblr-shadow-card, 0 0.5rem 1.5rem rgba(24, 36, 51, 0.16));
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform 0.22s ease, visibility 0.22s ease;
    }

    #navbar-menu.show {
        transform: translateX(0);
        visibility: visible;
    }

    #navbar-menu.collapsing {
        height: auto !important;
        overflow: hidden;
        transition: transform 0.22s ease;
    }

    #navbar-menu > .navbar,
    #navbar-menu > .navbar > .container-xl {
        display: block;
        width: 100%;
        padding-inline: 0;
    }

    #navbar-menu .navbar-nav {
        display: block;
        width: 100%;
    }

    #navbar-menu .nav-link {
        padding: 0.7rem 1rem;
    }

    #navbar-menu .dropdown-menu {
        position: static;
        float: none;
        width: auto;
        margin: 0 0 0 1rem;
        box-shadow: none;
    }
}

@media (min-width: 992px) {
    .si-mobile-nav-backdrop {
        display: none;
    }
}

/* Font stack - background left to Tabler's CSS variables so dark mode works */
body {
    font-family: "Inter Var", Inter, -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
}

.si-payment-method {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.si-payment-method .si-payment-icon {
    transition: transform 0.15s ease;
}

.si-payment-method .si-payment-icon:hover {
    transform: scale(1.1);
    z-index: 1;
}

/* Compact payment method display for invoice details */
.si-payment-method-compact {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.si-payment-method-compact .si-payment-icon {
    width: 2rem;
    height: 1.25rem;
}

/* Prominent payment method display for quick view */
.si-payment-method-prominent {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.si-payment-prominent-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: 0.5rem;
    background: var(--tblr-bg-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.si-payment-prominent-item:hover {
    border-color: var(--tblr-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.si-payment-prominent-item .si-payment-icon {
    width: 3rem;
    height: 1.875rem;
}

.si-payment-prominent-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--tblr-body-color);
    line-height: 1.2;
}

.si-payment-icon {
    flex: 0 0 auto;
    height: 1.5rem;
    width: 2.5rem;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    object-fit: contain;
    border-radius: 0.375rem;
    box-shadow: 0 0 0 1px rgba(4, 32, 69, 0.08);
    vertical-align: middle;
}

.si-payment-provider-paypal { background-image: url("../../invoices/img/payments/paypal.svg"); }
.si-payment-provider-stripe { background-image: url("../../invoices/img/payments/stripe.svg"); }
.si-payment-provider-adyen { background-image: url("../../invoices/img/payments/adyen.svg"); }
.si-payment-provider-authorize { background-image: url("../../invoices/img/payments/authorize.svg"); }
.si-payment-provider-eway { background-image: url("../../invoices/img/payments/eway.svg"); }
.si-payment-provider-visa { background-image: url("../../invoices/img/payments/visa.svg"); }
.si-payment-provider-mastercard { background-image: url("../../invoices/img/payments/mastercard.svg"); }
.si-payment-provider-americanexpress { background-image: url("../../invoices/img/payments/americanexpress.svg"); }
.si-payment-provider-applepay { background-image: url("../../invoices/img/payments/applepay.svg"); }
.si-payment-provider-google-pay { background-image: url("../../invoices/img/payments/google-pay.svg"); }
.si-payment-provider-shop-pay { background-image: url("../../invoices/img/payments/shop-pay.svg"); }
.si-payment-provider-cash-app { background-image: url("../../invoices/img/payments/cash-app.svg"); }
.si-payment-provider-bitcoin { background-image: url("../../invoices/img/payments/bitcoin.svg"); }
.si-payment-provider-ethereum { background-image: url("../../invoices/img/payments/ethereum.svg"); }
.si-payment-provider-litecoin { background-image: url("../../invoices/img/payments/litecoin.svg"); }
.si-payment-provider-klarna { background-image: url("../../invoices/img/payments/klarna.svg"); }
.si-payment-provider-skrill { background-image: url("../../invoices/img/payments/skrill.svg"); }
.si-payment-provider-braintree { background-image: url("../../invoices/img/payments/braintree.svg"); }
.si-payment-provider-square { background-image: url("../../invoices/img/payments/square.svg"); }
.si-payment-provider-shopify { background-image: url("../../invoices/img/payments/shopify.svg"); }
.si-payment-provider-sage { background-image: url("../../invoices/img/payments/sage.svg"); }
.si-payment-provider-worldpay { background-image: url("../../invoices/img/payments/worldpay.svg"); }
.si-payment-provider-dinersclub { background-image: url("../../invoices/img/payments/dinersclub.svg"); }
.si-payment-provider-discover { background-image: url("../../invoices/img/payments/discover.svg"); }
.si-payment-provider-jcb { background-image: url("../../invoices/img/payments/jcb.svg"); }
.si-payment-provider-unionpay { background-image: url("../../invoices/img/payments/unionpay.svg"); }
.si-payment-provider-sepa { background-image: url("../../invoices/img/payments/sepa.svg"); }
.si-payment-provider-ideal { background-image: url("../../invoices/img/payments/ideal.svg"); }
.si-payment-provider-giropay { background-image: url("../../invoices/img/payments/giropay.svg"); }
.si-payment-provider-bancontact { background-image: url("../../invoices/img/payments/bancontact.svg"); }
.si-payment-provider-alipay { background-image: url("../../invoices/img/payments/alipay.svg"); }
.si-payment-provider-we-chat-pay { background-image: url("../../invoices/img/payments/we-chat-pay.svg"); }
.si-payment-provider-bitpay { background-image: url("../../invoices/img/payments/bitpay.svg"); }
.si-payment-provider-monero { background-image: url("../../invoices/img/payments/monero.svg"); }
.si-payment-provider-tether { background-image: url("../../invoices/img/payments/tether.svg"); }
.si-payment-provider-solana { background-image: url("../../invoices/img/payments/solana.svg"); }
.si-payment-provider-ripple { background-image: url("../../invoices/img/payments/ripple.svg"); }
.si-payment-provider-metamask { background-image: url("../../invoices/img/payments/metamask.svg"); }
.si-payment-provider-binance-usd { background-image: url("../../invoices/img/payments/binance-usd.svg"); }
.si-payment-provider-venmo { background-image: url("../../invoices/img/payments/venmo.svg"); }
.si-payment-provider-zelle { background-image: url("../../invoices/img/payments/zelle.svg"); }
.si-payment-provider-wise { background-image: url("../../invoices/img/payments/wise.svg"); }
.si-payment-provider-westernunion { background-image: url("../../invoices/img/payments/westernunion.svg"); }
.si-payment-provider-moneygram { background-image: url("../../invoices/img/payments/moneygram.svg"); }
.si-payment-provider-maestro { background-image: url("../../invoices/img/payments/maestro.svg"); }
.si-payment-provider-mir { background-image: url("../../invoices/img/payments/mir.svg"); }
.si-payment-provider-samsung-pay { background-image: url("../../invoices/img/payments/samsung-pay.svg"); }
.si-payment-provider-verifone { background-image: url("../../invoices/img/payments/verifone.svg"); }
.si-payment-provider-revolut-pay { background-image: url("../../invoices/img/payments/revolut-pay.svg"); }
.si-payment-provider-affirm { background-image: url("../../invoices/img/payments/affirm.svg"); }
.si-payment-provider-afterpay { background-image: url("../../invoices/img/payments/affirm.svg"); }
.si-payment-provider-paysafe { background-image: url("../../invoices/img/payments/paysafe.svg"); }
.si-payment-provider-neteller { background-image: url("../../invoices/img/payments/neteller.svg"); }
.si-payment-provider-payoneer { background-image: url("../../invoices/img/payments/payoneer.svg"); }
.si-payment-provider-payu { background-image: url("../../invoices/img/payments/payu.svg"); }
.si-payment-provider-payza { background-image: url("../../invoices/img/payments/payza.svg"); }
.si-payment-provider-webmoney { background-image: url("../../invoices/img/payments/webmoney.svg"); }
.si-payment-provider-dwolla { background-image: url("../../invoices/img/payments/dwolla.svg"); }
.si-payment-provider-paymill { background-image: url("../../invoices/img/payments/paymill.svg"); }
.si-payment-provider-payone { background-image: url("../../invoices/img/payments/payone.svg"); }
.si-payment-provider-stax { background-image: url("../../invoices/img/payments/stax.svg"); }
.si-payment-provider-spingo { background-image: url("../../invoices/img/payments/spingo.svg"); }
.si-payment-provider-solo { background-image: url("../../invoices/img/payments/solo.svg"); }
.si-payment-provider-switch { background-image: url("../../invoices/img/payments/switch.svg"); }
.si-payment-provider-laser { background-image: url("../../invoices/img/payments/laser.svg"); }
.si-payment-provider-ogone { background-image: url("../../invoices/img/payments/ogone.svg"); }
.si-payment-provider-okpay { background-image: url("../../invoices/img/payments/okpay.svg"); }
.si-payment-provider-paybox { background-image: url("../../invoices/img/payments/paybox.svg"); }
.si-payment-provider-paysafecard { background-image: url("../../invoices/img/payments/paysafecard.svg"); }
.si-payment-provider-2checkout { background-image: url("../../invoices/img/payments/2checkout.svg"); }
.si-payment-provider-amazon-pay { background-image: url("../../invoices/img/payments/amazon-pay.svg"); }
.si-payment-provider-googlewallet { background-image: url("../../invoices/img/payments/googlewallet.svg"); }

.si-payment-option-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.si-payment-option-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: 999px;
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
    font-size: 0.8125rem;
    line-height: 1.2;
    white-space: nowrap;
}

.si-payment-option-badge .si-payment-icon {
    width: 2rem;
    height: 1.2rem;
}

/* Wizard payment providers grid display */
.si-wizard-payment-providers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.si-wizard-payment-provider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius-lg);
    transition: all 0.2s ease;
}

.si-wizard-payment-provider:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    border-color: var(--tblr-border-hover-color, var(--tblr-border-color));
}

.si-wizard-payment-provider .si-payment-icon {
    width: 3rem;
    height: 2rem;
    box-shadow: none;
    border-radius: 0.25rem;
}

.si-wizard-payment-provider span {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--tblr-secondary);
    text-align: center;
    line-height: 1.2;
}

/* Compact inline payment badges for bank section */
.si-payment-badges-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.si-payment-badge-compact {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    background: var(--tblr-bg-surface-secondary);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--tblr-body-color);
}

.si-payment-badge-compact .si-payment-icon {
    width: 1.75rem;
    height: 1rem;
    box-shadow: none;
}

/* Payment icons in buttons (online payment links) */
.btn .si-payment-icon {
    width: 1.5rem;
    height: 1rem;
    vertical-align: middle;
    box-shadow: none;
    border-radius: 0.25rem;
    margin-right: 0.35rem;
}

.btn-lg .si-payment-icon {
    width: 1.75rem;
    height: 1.15rem;
}

.btn-sm .si-payment-icon {
    width: 1.25rem;
    height: 0.85rem;
}

/* Remove default Tabler page-body margins and page-header top margin */
.page-body {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.page-wrapper .page-header {
    margin-top: 0 !important;
}

/* Page header styling (OVERVIEW / Dashboard row) - transparent like Tabler demo */
.page-header {
    background: transparent;
    border-bottom: none;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
}
.page-pretitle {
    text-transform: uppercase;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--tblr-secondary);
    margin-bottom: 0.125rem;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

/* Legacy flexigrid / manage grid integration */
.flexigrid {
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    overflow: hidden;
    background: var(--tblr-bg-surface);
}
.flexigrid table {
    width: 100%;
    border-collapse: collapse;
}
.flexigrid th,
.flexigrid td {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--tblr-border-color);
    vertical-align: middle;
}
.flexigrid thead th {
    background: var(--tblr-bg-surface-secondary);
    font-weight: 600;
    color: var(--tblr-body-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.flexigrid tbody tr:hover {
    background: rgba(var(--tblr-primary-rgb), 0.04);
}
.flexigrid .pDiv {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
}
.flexigrid .pDiv input {
    width: 50px;
    text-align: center;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    font-size: 0.8125rem;
}
.flexigrid .pGroup .pcontrol,
.flexigrid .pGroup span {
    vertical-align: middle;
}
.flexigrid .hDiv {
    overflow: hidden;
}
.flexigrid .bDiv {
    overflow: auto;
}

/* Legacy hide/show utility */
.si_hide { display: none !important; }

/* Invoice line items - responsive grid layout */

/* Button-sized segmented control - matches .btn default sizing */
.segmented-control-btn .segmented-control-label {
    padding: 0.4375rem 1rem;
    font-size: 0.875rem;
    font-weight: 400;
}
.segmented-control-btn .ti {
    font-size: 1.25rem;
    vertical-align: middle;
}

/* Compact segmented control for line item actions (expand/delete) */
.segmented-control-sm .segmented-control-label {
    padding: 0.2rem 0.45rem;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Line item action icons (expand, toggle-all) */
.si-expand-desc .ti,
.si-toggle-all-desc .ti { font-size: 1rem; }

/* Mobile: each line item renders as a card */
@media (max-width: 991.98px) {
    .si-line-item {
        border: 1px solid var(--tblr-border-color);
        border-radius: var(--tblr-border-radius);
        padding: 0.625rem;
        margin-bottom: 0.5rem;
        background: var(--tblr-bg-surface);
    }

    /* Separator between qty+product row and taxes+price row */
    .si-mobile-row-break {
        border-top: 1px solid var(--tblr-border-color-light, #e6e7e9);
        margin-top: 0.125rem;
        margin-bottom: 0.125rem;
    }

    /* Unit price label right-aligned on mobile to match the right-aligned input */
    .si-unit-price-col .form-label {
        text-align: right;
        display: block;
    }
}

/* Tax box: keep the rate on ONE line; only wrap if it genuinely does not fit,
   and when it wraps the box must grow DOWNWARD (not push its row siblings up).
   align-items-start on the row already keeps the box top-aligned. */
.si-tax-display {
    min-height: calc(1.5em + 0.75rem + 2px);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop: subtle separator between items */
@media (min-width: 992px) {
    .si-line-item {
        padding: 0.25rem 0.25rem;
        margin-bottom: 0.25rem;
    }
    .si-line-item + .si-line-item {
        border-top: 1px solid var(--tblr-border-color-light, #e6e7e9);
    }
    /* Keep the unit-price box compact and cap the tax column so the rate stays
       on one line instead of wrapping unnecessarily. The unit-price column is
       given a fixed width equal to its input so the narrow box no longer
       floats left inside a wide Bootstrap column (looked "misplaced"). */
    .si-unit-price-col {
        width: 8.5rem;
        max-width: 8.5rem;
    }
    .si-tax-col {
        max-width: 17rem;
    }
}

/* Hover reveal: show the COMPLETE tax line when hovering the tax box.
   Normally the rate is clipped to one line (ellipsis); on hover the box
   expands to show the full tax description. */
.si-tax-col .si-tax-display {
    cursor: default;
}
.si-tax-col:hover .si-tax-display {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    position: relative;
    z-index: 5;
}
/* On the line-item row keep the box top-aligned so the expansion grows
   downward and does not push its siblings up. */
.si-line-item .si-tax-col:hover {
    z-index: 5;
}

/* Legacy SI class compatibility */
.si_message {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--tblr-border-radius);
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    color: var(--tblr-secondary);
}
.si_message_ok {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--tblr-border-radius);
    background: var(--tblr-success-lt);
    border: 1px solid rgba(var(--tblr-success-rgb), 0.3);
    color: var(--tblr-success);
}
.si_message_error {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--tblr-border-radius);
    background: var(--tblr-danger-lt);
    border: 1px solid rgba(var(--tblr-danger-rgb), 0.3);
    color: var(--tblr-danger);
}

/* Save result screens */
.si-save-card {
    width: 100%;
    max-width: none;
}

.si-save-alert {
    width: 100%;
    padding: 1rem 1.125rem;
    border-radius: calc(var(--tblr-border-radius) + 2px);
    margin-bottom: 0;
}

.si-save-alert .alert-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tblr-body-color);
}

.si-save-alert .text-secondary {
    line-height: 1.55;
}

.si-save-alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 1.5rem;
    min-width: 1.5rem;
    font-size: 1.25rem;
    line-height: 1;
    margin-top: 0.125rem;
}

.si-save-alert.alert-success .si-save-alert-icon {
    color: var(--tblr-success);
}

.si-save-alert.alert-warning .si-save-alert-icon {
    color: var(--tblr-warning);
}

.si-save-alert-note {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--tblr-secondary);
}

/* Legacy toolbar (manage pages) */
.si_toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.si_toolbar a {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--tblr-body-color);
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.si_toolbar a:hover {
    background: var(--tblr-bg-surface-secondary);
    border-color: var(--tblr-border-color-active);
}
.si_toolbar a img {
    width: 16px;
    height: 16px;
}

/* Legacy toolbar dialog (export options) */
.si_toolbar_dialog {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 0;
}

/* Legacy form layout */
.si_form {
    margin-bottom: 1.5rem;
}
.si_form table {
    width: 100%;
    border-collapse: collapse;
}
.si_form table th {
    text-align: right;
    padding: 0.5rem 1rem 0.5rem 0;
    font-weight: 500;
    width: 30%;
    vertical-align: top;
    color: var(--tblr-secondary);
    font-size: 0.875rem;
}
.si_form table td {
    padding: 0.5rem 0;
}
.si_form input[type="text"],
.si_form input[type="email"],
.si_form input[type="password"],
.si_form input[type="number"],
.si_form select,
.si_form textarea {
    display: block;
    width: 100%;
    max-width: 400px;
    padding: 0.4375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.4285714286;
    color: var(--tblr-body-color);
    background: var(--tblr-bg-forms);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.si_form input:focus,
.si_form select:focus,
.si_form textarea:focus {
    border-color: var(--tblr-primary);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(var(--tblr-primary-rgb), 0.25);
}

.si_form_view table th {
    color: var(--tblr-secondary);
}
.si_form_view table td {
    font-weight: 500;
}

/* Toolbar buttons (save/cancel) */
.si_toolbar_form {
    display: flex;
    gap: 0.5rem;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--tblr-border-color);
}
.si_toolbar_form button,
.si_toolbar_form .positive {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--tblr-border-radius);
    text-decoration: none;
    cursor: pointer;
}
.si_toolbar_form button.positive,
.si_toolbar_form button[type="submit"] {
    color: #fff;
    background: var(--tblr-primary);
    border: 1px solid var(--tblr-primary);
}
.si_toolbar_form button.positive:hover,
.si_toolbar_form button[type="submit"]:hover {
    background: var(--tblr-primary-darken);
}
.si_toolbar_form a.positive {
    color: #fff;
    background: var(--tblr-primary);
    border: 1px solid var(--tblr-primary);
}
.si_toolbar_form a.positive:hover {
    background: var(--tblr-primary-darken);
}
.si_toolbar_form a.negative {
    color: var(--tblr-body-color);
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
}
.si_toolbar_form a.negative:hover {
    background: var(--tblr-bg-surface-secondary);
}
.si_toolbar_form img {
    width: 16px;
    height: 16px;
}

/* Invoice manage filters */
.si_filters_invoices {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}
.si_filters_title {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--tblr-secondary);
}
.si_filters_links {
    display: flex;
    gap: 0;
}
.si_filters_links a {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--tblr-secondary);
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    text-decoration: none;
    margin-left: -1px;
}
.si_filters_links a:first-child,
.si_filters_links a.first {
    border-radius: var(--tblr-border-radius) 0 0 var(--tblr-border-radius);
    margin-left: 0;
}
.si_filters_links a:last-child {
    border-radius: 0 var(--tblr-border-radius) var(--tblr-border-radius) 0;
}
.si_filters_links a:hover {
    background: var(--tblr-bg-surface-secondary);
    z-index: 1;
}
.si_filters_links a.selected {
    background: var(--tblr-primary);
    border-color: var(--tblr-primary);
    color: #fff;
    z-index: 2;
}

/* Legacy index page link grids */
.si_index h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--tblr-border-color);
}
.si_index h2:first-child {
    margin-top: 0;
}

/* Settings index cards */
.si_index_settings .si_toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.si_index_settings .si_toolbar a {
    flex-direction: column;
    padding: 1rem;
    text-align: center;
    gap: 0.5rem;
}
.si_index_settings .si_toolbar a img {
    width: 24px;
    height: 24px;
}

/* Help links */
.si_help_div {
    padding: 0.75rem 0;
    font-size: 0.8125rem;
}
.si_help_div a {
    color: var(--tblr-secondary);
    text-decoration: none;
}
.si_help_div a:hover {
    color: var(--tblr-primary);
}
.si_help_div img {
    width: 14px;
    height: 14px;
    margin-left: 2px;
}

/* Legacy tables (manage tables, etc.) */
table.manage,
table#live-grid {
    width: 100%;
    border-collapse: collapse;
}
table.manage th,
table#live-grid th {
    background: var(--tblr-bg-surface-secondary);
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tblr-secondary);
    border-bottom: 1px solid var(--tblr-border-color);
}
table.manage td,
table#live-grid td {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--tblr-border-color);
    vertical-align: middle;
}
table.manage tbody tr:hover,
table#live-grid tbody tr:hover {
    background: rgba(var(--tblr-primary-rgb), 0.04);
}
td.index_table {
    vertical-align: middle;
}

/* Quick view / details action toolbars */
.si_toolbar_top {
    margin-bottom: 1rem;
}
.si_toolbar_top_left {
    justify-content: flex-start;
}

/* Print-only */
.print_only { display: none; }

@media print {
    .print_only { display: block; }
    .d-print-none { display: none !important; }
    .navbar { display: none !important; }
    .page-header { display: none !important; }
    .footer { display: none !important; }
}

/* jQuery UI dialog overrides for Tabler compatibility */
.ui-dialog {
    border-radius: var(--tblr-border-radius);
    border: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
    box-shadow: var(--tblr-box-shadow);
    padding: 0;
}
.ui-dialog-titlebar {
    padding: 0.75rem 1rem;
    background: var(--tblr-bg-surface-secondary);
    border-bottom: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius) var(--tblr-border-radius) 0 0;
}
.ui-dialog-content {
    padding: 1rem;
}

/* jQuery datepicker overrides */
.ui-datepicker {
    border-radius: var(--tblr-border-radius);
    border: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
    box-shadow: var(--tblr-box-shadow);
    padding: 0.5rem;
}

/* Ensure old images don't break layout */
.si_toolbar img,
.si_form img,
.si_toolbar_form img {
    max-width: 20px;
    height: auto;
}

/* Quick view invoice */
.si_invoice_quick_view {
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* Statement / invoice print view */
.si_invoice_content table {
    width: 100%;
}

/* Remove old background */
.si_grey_background { display: none; }

/* Center util */
.si_center { text-align: center; margin-bottom: 1rem; }

/* Allow dropdown menus to overflow the table-responsive wrapper */
.si-tabler-grid-container .table-responsive,
.si-dash-recent-table .table-responsive {
    overflow: visible;
}

.si-tabler-grid-container .dropdown-menu,
.si-dash-recent-table .dropdown-menu {
    z-index: 1050;
}

/* Icon sizing - matches Tabler demo nav proportions */
.nav-link .ti,
.nav-link-icon .ti,
.dropdown-item .ti {
    font-size: 1.25rem;
    vertical-align: middle;
}

.btn .ti {
    font-size: 1.25rem;
    vertical-align: middle;
}

/* Responsive small button - full size on sm+, icon-only compact on xs */
@media (max-width: 575.98px) {
    .btn-sm-mobile {
        --tblr-btn-padding-y: .2rem;
        --tblr-btn-padding-x: .35rem;
        padding: .2rem .35rem;          /* explicit fallback if CSS vars aren't picked up */
        font-size: .875rem;
        border-radius: var(--tblr-border-radius-sm, .25rem);
    }
    .btn-sm-mobile .ti {
        font-size: 1rem;
    }
    /* Hide the dropdown caret - the ⋮ icon already signals a menu, and the
       ::after triangle pushes the button ~5px wider than the 2.5rem column. */
    .btn-sm-mobile::after {
        display: none !important;
    }
    /* Card headers are Tabler flex (no wrap): on a phone the title + action
     * buttons (e.g. "Recent Invoices" + View all / + Add Invoice, or the chart
     * title + "Last 12 months" dropdown) can crowd and overflow. Let them wrap
     * to a second line instead. card-options already carries ms-auto so it
     * drops cleanly below the title. */
    .card-header {
        flex-wrap: wrap;
        row-gap: var(--si-space-2, .5rem);
    }
}

/* Segmented control (not in Tabler v1.4.0, polyfilled here) */
.segmented-control {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    gap: 2px;
    background: var(--tblr-bg-surface-secondary, #f1f5f9);
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
}

.segmented-control-item {
    display: flex;
    margin: 0;
    cursor: pointer;
}

.segmented-control-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.segmented-control-label {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    border-radius: calc(var(--tblr-border-radius) - 1px);
    color: var(--tblr-secondary);
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    transition: color 0.1s ease-in-out, background-color 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
}

.segmented-control-item:hover .segmented-control-label {
    color: var(--tblr-body-color);
    background: rgba(0, 0, 0, 0.06);
}

.segmented-control-input:checked + .segmented-control-label {
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
    box-shadow: var(--tblr-box-shadow-sm, 0 1px 2px rgba(0,0,0,.08));
}

/* Segmented control as navigation links (e.g. new invoice type) */
a.segmented-control-item {
    text-decoration: none;
    color: inherit;
}
.segmented-control-item.active .segmented-control-label,
.segmented-control-item[aria-current="page"] .segmented-control-label {
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
    box-shadow: var(--tblr-box-shadow-sm, 0 1px 2px rgba(0,0,0,.08));
}
.segmented-control-item.active:hover .segmented-control-label,
.segmented-control-item[aria-current="page"]:hover .segmented-control-label {
    color: var(--tblr-body-color);
}

/* Help popovers (content loaded from documentation page) */
.si-help-popover.popover {
    max-width: 360px;
}
.si-help-popover .popover-body {
    max-height: 20rem;
    overflow-y: auto;
}

/* Report tables: lightweight client-side sorting */
.si-report-sortable thead th[aria-sort] {
    white-space: nowrap;
}

.si-report-sort-trigger {
    cursor: pointer;
    user-select: none;
}

.si-report-sort-trigger:focus-visible {
    outline: 2px solid rgba(var(--tblr-primary-rgb), 0.35);
    outline-offset: -2px;
}

.si-report-sort-icon {
    font-size: 1rem;
    margin-left: 0.35rem;
    color: var(--tblr-secondary);
    vertical-align: middle;
}

.si-report-sort-trigger[aria-sort="ascending"] .si-report-sort-icon,
.si-report-sort-trigger[aria-sort="descending"] .si-report-sort-icon {
    color: var(--tblr-primary);
}

/* ── Tom Select ─────────────────────────────────────────────────────────── */

/*
 * The bootstrap5 theme sets the control background to `transparent` and uses
 * `var(--bs-body-bg)` for the dropdown - both of which can produce a see-through
 * appearance inside Tabler's stacking contexts.  Override with Tabler's own
 * surface token so both light and dark modes always get a solid, opaque panel.
 */

/* Control (the visible input area) */
.ts-wrapper.form-select .ts-control,
.ts-wrapper.form-select.single.input-active .ts-control {
    background: #fff !important;
    color: var(--tblr-body-color);
}

/* Prevent the selected value from wrapping - matches native <select> behaviour */
.ts-wrapper.single .ts-control {
    flex-wrap: nowrap;
    overflow: hidden;
}
.ts-wrapper.single .ts-control .item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Strip Bootstrap's X icon from all invalid fields - red border is enough */
.form-control.is-invalid,
.form-select.is-invalid,
.was-validated .form-control:invalid,
.was-validated .form-select:invalid {
    background-image: none;
    padding-right: inherit;
}

/* Validation state: red border on the wrapper (TomSelect sets border: none on .ts-control) */
.ts-wrapper.is-invalid {
    border: 1px solid #dc3545 !important;
    box-shadow: 0 0 0 1px #dc3545 !important;
    background-image: none !important;
}

/* Root fix: SI validates red-only (si-validate.js never adds is-valid /
   was-validated). Tabler's base CSS paints any .is-valid / was-validated
   field green with a checkmark - including unconstrained and
   "wrong-but-required-satisfied" input - so boxes turn green and a tick
   appears on bad data. Neutralize the valid-state paint (it is only ever
   attached via the .is-valid class or a .was-validated form, never on
   plain :valid fields) so only invalid fields are ever highlighted.
   ponytail: red-only by design; if a deliberate green-success affordance is
   ever wanted, add a scoped class (e.g. .is-valid-lite) instead of
   re-enabling Tabler's global valid paint. */
.form-control.is-valid,
textarea.form-control.is-valid,
.form-select.is-valid,
.form-check-input.is-valid,
.ts-wrapper.is-valid,
.was-validated .form-control:valid,
.was-validated textarea.form-control:valid,
.was-validated .form-select:valid,
.was-validated .form-check-input:valid {
    border-color: var(--tblr-border-color) !important;
    padding-right: inherit !important;
    background-image: none !important;
    box-shadow: none !important;
    --tblr-form-select-bg-icon: none !important;
}

/* Dropdown panel - solid background, decent shadow, rounded corners */
.ts-dropdown,
.ts-dropdown.form-control,
.ts-dropdown.form-select {
    background: #fff !important;
    background-color: #fff !important;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 1060;
    color: var(--tblr-body-color);
}

/* Dark mode - override with a solid dark surface */
/* .table-light rows (line attributes / descriptions / product custom fields in
   quick_view) ship a near-white #f9fafb background in Tabler with NO dark-mode
   gate — so they blaze white in dark mode. Re-point the variant tokens at the
   dark surface so the row blends in like every other row. */
[data-bs-theme="dark"] .table-light {
    --tblr-table-bg: var(--tblr-bg-surface-secondary);
    --tblr-table-color: var(--tblr-body-color);
    --tblr-table-border-color: var(--tblr-border-color);
}
[data-bs-theme="dark"] .table-light > :not(caption) > * > * {
    background-color: var(--tblr-bg-surface-secondary);
    color: var(--tblr-body-color);
}

/* .btn-light (used for the Verify/Rebuild action cards on invoice_denorm and
   elsewhere) ships a near-white #f8f9fa background with no dark-mode gate, so
   it blazes white in dark mode. Re-point at the dark surface. */
[data-bs-theme="dark"] .btn-light {
    --tblr-btn-bg: var(--tblr-bg-surface-secondary);
    --tblr-btn-color: var(--tblr-body-color);
    --tblr-btn-border-color: var(--tblr-border-color);
    --tblr-btn-hover-bg: var(--tblr-bg-surface-tertiary, #334155);
    --tblr-btn-hover-color: var(--tblr-body-color);
    --tblr-btn-hover-border-color: var(--tblr-border-color);
    --tblr-btn-active-bg: var(--tblr-bg-surface-tertiary, #334155);
    --tblr-btn-active-color: var(--tblr-body-color);
}

[data-bs-theme="dark"] .ts-wrapper.form-select .ts-control,
[data-bs-theme="dark"] .ts-wrapper.form-select.single.input-active .ts-control {
    background: #1e293b !important;
}
[data-bs-theme="dark"] .ts-dropdown,
[data-bs-theme="dark"] .ts-dropdown.form-control,
[data-bs-theme="dark"] .ts-dropdown.form-select {
    background: #1e293b !important;
    background-color: #1e293b !important;
    border-color: rgba(255, 255, 255, 0.12);
}

/* Hover / keyboard-active row */
.ts-dropdown .option.active,
.ts-dropdown .option:hover {
    background-color: var(--tblr-primary);
    color: #fff;
    border-radius: calc(var(--tblr-border-radius) - 1px);
}

/* Adequate touch targets for option rows */
.ts-dropdown .option {
    min-height: 2.25rem;
    display: flex;
    align-items: center;
}

/* ── Tom Select sizing: match Tabler form-select heights ────────────────── */
/* TomSelect's bootstrap5 theme already sets padding:0 on .ts-wrapper.form-select,
   so height is driven by .ts-control alone.  The critical fix is using Tabler's
   actual form-select padding (.5625rem vertical, 1rem left) rather than the
   form-control padding (0.4375rem) that --tblr-input-padding-y resolves to -
   those differ by 4px per side, making TomSelect visibly shorter than native
   form-select elements. */
.ts-wrapper.form-select,
.ts-wrapper.form-select-sm {
    padding: 0 !important;
    height: auto !important;
}

.ts-wrapper.form-select .ts-control,
.ts-wrapper.form-select.single.input-active .ts-control {
    /* 0.5625rem matches Tabler's form-select padding-y exactly */
    padding-top: 0.5625rem;
    padding-bottom: 0.5625rem;
    padding-left: 1rem;
    min-height: unset;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.ts-wrapper.form-select-sm .ts-control,
.ts-wrapper.form-select-sm.single.input-active .ts-control {
    padding: var(--tblr-input-padding-y-sm, 0.25rem) var(--tblr-input-padding-x-sm, 0.5rem);
    min-height: unset;
    font-size: var(--tblr-input-font-size-sm, 0.875rem);
    line-height: var(--tblr-input-line-height, 1.4285714286);
}

/* ── Quick-add buttons (product + / customer + / biller +) ──────────────── */
/* Match the muted secondary colour used by the segmented-control row buttons */
.si-add-customer-btn,
.si-add-product-row-btn,
.si-add-biller-btn {
    color: var(--tblr-secondary);
    border-color: var(--tblr-border-color);
    background: transparent;
}
.si-add-customer-btn:hover,
.si-add-product-row-btn:hover,
.si-add-biller-btn:hover {
    color: var(--tblr-body-color);
    border-color: var(--tblr-border-color);
    background-color: rgba(0, 0, 0, 0.06);
}

/* ── Mobile + tablet grid / table fixes ─────────────────────────────────────
 * table-layout: auto lets a table exceed width:100% to fit content, even
 * inside a table-responsive scroll wrapper.  Switch to fixed on small screens
 * so the table cannot be wider than its container, and truncate cell text.
 * Covers up to 991.98px: the .table-responsive wrapper is overflow:visible
 * (so Actions dropdowns can escape), which means any table wider than its
 * parent bleeds instead of scrolling. Tablets need the same guard as phones.
 */
@media (max-width: 991.98px) {
    /* Grid (siTablerGrid) and dashboard recent-invoice/payment tables */
    .si-tabler-grid-container .table,
    .si-dash-recent-table .table {
        table-layout: fixed;
    }
    /* Give the actions column (w-1) an explicit width.
     * Tabler's .w-1 sets width:1%!important so we need !important to win. */
    .si-tabler-grid-container .table .w-1,
    .si-dash-recent-table .table .w-1 {
        width: 2.5rem !important;
    }
    /* Actions toggle: at this width the column is pinned to 2.5rem (grid/dash)
     * or ~1% (fbr-log), so the "Actions" word + caret are wider than the cell
     * and paint over the Invoice-ID / first column ("Action45"). Force the
     * toggle to icon-only (the dots glyph) and clip the BUTTON so it can never
     * spill into the neighbour. The open dropdown panel is a SIBLING of the
     * button (not a child), so it still escapes the narrow cell via the
     * overflow:visible set on the cell below. Covers the dashboard recent
     * tables, the siTablerGrid Manage pages, and the FBR log table. */
    .si-tabler-grid-container .table td.w-1 .btn .d-sm-inline-flex,
    .si-dash-recent-table .table td.w-1 .btn .d-sm-inline-flex,
    .table-responsive-fbr-log .table td.w-1 .btn .d-sm-inline-flex {
        display: none !important;
    }
    /* Reveal the dots glyph (normally phone-only) as the tablet icon. Scoped to
     * the actions button so it doesn't also un-hide customer/status short spans. */
    .si-tabler-grid-container .table td.w-1 .btn .d-sm-none,
    .si-dash-recent-table .table td.w-1 .btn .d-sm-none,
    .table-responsive-fbr-log .table td.w-1 .btn .d-sm-none {
        display: inline-flex !important;
    }
    .si-tabler-grid-container .table td.w-1 > .dropdown > .btn,
    .si-dash-recent-table .table td.w-1 > .dropdown > .btn,
    .table-responsive-fbr-log .table td.w-1 > .dropdown > .btn {
        /* !important: the later @media (max-width:991.98px) block (tap-target
         * rule) sets min-width:var(--si-tap-min) (~44px) on .dropdown-toggle,
         * which beats a non-important max-width and forces the button wider than
         * the 2.5rem (40px) w-1 cell -> it overflows into the invoice-ID column.
         * min-width:0 + max-width:2.5rem (both !important) let it shrink to fit. */
        min-width: 0 !important;
        max-width: 2.5rem !important;
        overflow: hidden !important;
        padding-left: .35rem;
        padding-right: .35rem;
    }
    /* Invoice-ID / first data column (grid + dashboard): clip with ellipsis as a
     * reciprocal guard so it can never be overlapped by the actions button. */
    .si-tabler-grid-container .table td:nth-child(2),
    .si-dash-recent-table .table td:nth-child(2) {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    /* Data cells: clip overflowing text instead of stretching the column.
     * overflow:visible on the w-1 (actions) cell lets the open dropdown menu
     * escape its narrow column without being clipped. */
    .si-tabler-grid-container .table th:not(.w-1),
    .si-dash-recent-table .table th:not(.w-1) {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    .si-tabler-grid-container .table td:not(.w-1),
    .si-dash-recent-table .table td:not(.w-1) {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    /* Actions column td: allow the dropdown panel to escape its narrow cell */
    .si-tabler-grid-container .table td.w-1,
    .si-dash-recent-table .table td.w-1 {
        overflow: visible;
    }
}

/* Phones only: dropdown menus inside grid tables open to the right so they
 * don't cover the invoice-ID column. Bootstrap's dropdown-menu-end + Popper
 * flips to bottom-start on mobile which lands directly over that column.
 * Tablets have room for the default placement, so this stays phone-scoped. */
@media (max-width: 575.98px) {
    .si-tabler-grid-container .table .dropdown-menu,
    .si-dash-recent-table .table .dropdown-menu {
        right: auto !important;
        left:  0    !important;
    }
}

/* siTablerGrid toolbar search: single row, compact field selector */
.si-grid-search-input-group .form-select {
    flex: 0 1 auto;
    max-width: 11rem;
    width: auto;
}
/* Manage Invoices: narrower field selector so more room for the query input */
#manageGrid .si-grid-search-input-group .form-select {
    max-width: 8rem;
}
.si-grid-search-input-group .form-control {
    min-width: 0;
}
.si-grid-search-input-group input[name="q"] {
    min-width: 0;
}
/* Manage Invoices: Date-range mode — keep From/To pickers on the SAME row as the
   field dropdown (replacing the text query), only while "Date range" is selected.
   The theme's .input-group is flex-row at desktop but block inside the <992px
   search flyout, so force a single horizontal row here at every width. Inline
   !important on .si-date-range still controls show/hide (inline beats stylesheet). */
#manageGridToolbar .si-grid-search-input-group.si-date-mode {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.75rem;
}
#manageGridToolbar .si-grid-search-input-group.si-date-mode > * {
    flex: 0 0 auto;
}
#manageGridToolbar .si-grid-search-input-group.si-date-mode .si-date-range {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.75rem;
}
/* "to" separator: own space on both sides, vertically centered */
#manageGridToolbar .si-grid-search-input-group.si-date-mode .si-date-range > span {
    margin: 0 0.5rem;
    align-self: center;
    white-space: nowrap;
}

/* Payments grid mirrors invoices: its toolbar lives inside #manageGrid (no
   separate #manageGridToolbar), so scope the same single-row date rule there. */
#manageGrid .si-grid-search-input-group.si-date-mode {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.75rem;
}
#manageGrid .si-grid-search-input-group.si-date-mode > * {
    flex: 0 0 auto;
}
#manageGrid .si-grid-search-input-group.si-date-mode .si-date-range {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.75rem;
}
#manageGrid .si-grid-search-input-group.si-date-mode .si-date-range > span {
    margin: 0 0.5rem;
    align-self: center;
    white-space: nowrap;
}

/* Collapsible search: phones and tablets (below Bootstrap lg) */
@media (max-width: 991.98px) {
    /* Anchor the flyout so the toggle stays on the header row */
    .si-grid-search {
        position: relative;
        align-self: flex-end;
    }
    .si-grid-search-fields:not(.si-grid-search-fields--open) {
        display: none !important;
    }
    .si-grid-search-fields.si-grid-search-fields--open {
        display: block !important;
        position: absolute;
        top: 100%;
        right: 0;
        z-index: 1040;
        width: min(calc(100vw - 2rem), 36rem);
        margin-top: 0.25rem;
        padding: 0.75rem;
        background: var(--tblr-bg-surface, #fff);
        border: 1px solid var(--tblr-border-color, rgba(0, 0, 0, 0.08));
        border-radius: var(--tblr-border-radius, 0.25rem);
        box-shadow: var(--tblr-shadow-dropdown, 0 0.5rem 1rem rgba(0, 0, 0, 0.12));
    }
    .si-grid-search-fields.si-grid-search-fields--open .si-grid-search-input-group {
        width: 100%;
    }
}
@media (min-width: 992px) {
    .si-grid-search-toggle {
        display: none !important;
    }
    .si-grid-search-fields {
        display: block !important;
    }
}

/* Mobile: larger tap targets, capped height */
@media (max-width: 991.98px) {
    .ts-dropdown .option {
        min-height: 2.75rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .ts-dropdown {
        max-height: 40vh;
    }
}

/* ══════════════════════════════════════════════════════════════════════════
 * UI AUDIT PASS — touch targets, spacing scale, typography, long content
 * Visual-only: no desktop reflow, no behaviour changes.
 * ══════════════════════════════════════════════════════════════════════════ */

:root {
    --si-space-1: 0.25rem;
    --si-space-2: 0.5rem;
    --si-space-3: 0.75rem;
    --si-space-4: 1rem;
    --si-space-5: 1.5rem;
    --si-space-6: 2rem;
    --si-tap-min:  2.75rem;  /* 44px — comfortable tap target */
    --si-tap-min-sm: 2rem;   /* 32px — inline affordances (help icons) */
}

/* ── Typography ──────────────────────────────────────────────────────────────
 * Audit found .btn rendering at 4 size/weight/line-height combos and labels
 * at 2 weights for identical roles. Normalise onto Tabler's own scale.
 * .input-group-sm > .btn is Tabler's: it drops font-size to 12px but leaves
 * the 20px line-height, which is what created the 4th variant.
 */
.btn {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}
.btn-sm,
.btn-group-sm > .btn,
.input-group-sm > .btn,
.form-control-sm,
.form-select-sm {
    font-size: 0.75rem;
    line-height: 1rem;
}
.form-label,
form label:not(.form-check-label):not(.btn) {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}
.page-title,
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

/* ── Long content ────────────────────────────────────────────────────────────
 * Long names/emails/URLs must wrap rather than widen a column, and flex
 * children need min-width:0 or they refuse to shrink below content width.
 */
.si-tabler-grid-container .table td,
.si-dash-recent-table .table td {
    overflow-wrap: anywhere;
}
/* TOTAL (text-end) and STATUS (text-center) cells must stay on ONE line at any
 * viewport width. The nowrap guard in the <=991.98px block below does not cover
 * desktop, so on wide screens the long BILLER column can squeeze these cells
 * until money/status strings wrap mid-character (e.g. "Rs1,030.0" + "0",
 * "Unpai" + "d") — browsers disagree on where to break. Keep them intact;
 * BILLER already wraps (overflow-wrap:anywhere) so the two columns never fight
 * for width. overflow:hidden + ellipsis only kicks in if a cell is ever truly
 * too narrow. The more specific selector wins over the overflow-wrap:anywhere
 * rule above for these cells. */
.si-dash-recent-table .table td.text-end,
.si-dash-recent-table .table td.text-center {
    overflow-wrap: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-header .row > [class^="col"],
.card-header .row > [class^="col"] {
    min-width: 0;
}

/* Empty action slots collapse to 0x0 and skew header spacing — drop them. */
.page-header .col-auto:empty,
.page-header .col:empty,
.card-header .col-auto:empty {
    display: none;
}

/* ── Touch targets: phones + tablets ─────────────────────────────────────────
 * Audit @375px found the grid Actions toggle at 29x28 across 12 pages,
 * pagination and hamburger at 32x32, footer links ~17px tall. Pad to 44px
 * without altering visual weight; inline-flex keeps glyphs optically centred.
 */
@media (max-width: 991.98px) {
    .si-tabler-grid-container .table .dropdown-toggle,
    .si-dash-recent-table .table .dropdown-toggle,
    .pagination .page-link,
    .navbar-toggler,
    a.cluetip {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: var(--si-tap-min);
        min-height: var(--si-tap-min);
    }
    /* Inline help glyphs sit in running text — 32px is enough, 44 distorts it */
    a.cluetip {
        min-width: var(--si-tap-min-sm);
        min-height: var(--si-tap-min-sm);
    }
    .si-grid-search .btn,
    .si-tabler-grid-container .card-header .btn {
        min-height: var(--si-tap-min);
    }
    .footer .link-secondary {
        display: inline-block;
        padding-block: var(--si-space-2);
    }

    /* Right-aligned sortable headers are bare `text + <i class="ti">` with no
     * wrapper to flex. Combined with the nowrap ellipsis rule above, the icon
     * lands past the cell edge and overflow:hidden erases the sort state.
     * Flexing the th keeps the icon in-cell and truncates the label instead. */
    .si-tabler-grid-container .table th.text-end,
    .si-dash-recent-table .table th.text-end {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: var(--si-space-1);
    }
    .si-tabler-grid-container .table th.text-end > .ti,
    .si-dash-recent-table .table th.text-end > .ti {
        flex: 0 0 auto;
    }
}

/* Customer profile invoice history has five or six useful columns. Keep that
 * table readable in a narrow profile card and let it scroll inside its own
 * region instead of widening the whole screen. */
.si_cust_account {
    width: min(100%, 18.75rem);
    max-width: 100%;
}

.si_cust_invoices {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.si_cust_invoices > .table {
    min-width: 36rem;
}

/* Biller profile (view): the per-row .table bottom-border on the final row of
 * each category group (Details / Address / Contacts) renders as a divider line
 * between sections. There is no <hr> between them — the table border is what
 * reads as the separator. Drop the row borders inside these view tables so the
 * categories flow together without lines. The <h4> headers still label each
 * group. Scoped to the biller details card so other tables are unaffected. */
.card .tab-pane[id^="bill-view-"] table.table-wrap > :not(caption) > * > *,
.card .tab-pane[id^="bill-view-"] table.table-wrap > tbody > tr > td {
    border-bottom-width: 0;
}
.card .tab-pane[id^="bill-view-"] table.table-wrap {
    margin-bottom: 0.25rem;
}

/* Solid colored badges (bg-danger/bg-warning/bg-success/bg-info) inherit Tabler's
 * default --tblr-secondary grey text, which is near-invisible on saturated
 * backgrounds. Measured in BOTH themes (FBR log "Network retry"/"Business error"
 * pills, SQL-patch gate, domain-admin Enabled/Disabled):
 *   dark  - before: bg-warning 1.19, bg-danger 1.84, bg-success 1.76, bg-info 1.58
 *   light - before: bg-warning 2.27, bg-danger 1.04, bg-success 1.76, bg-info 1.58
 * Fix = high-contrast text chosen per background, applied to both themes. */
.badge.bg-danger,
.badge.bg-danger-subtle {
    color: #fff !important;
}
.badge.bg-warning {
    color: #1d1300 !important; /* near-black on amber: ~11:1 on #f59f00 */
}
.badge.bg-success {
    color: #051f0a !important; /* near-black on green: ~6.3:1 on #2fb344 */
}
.badge.bg-info {
    color: #06121f !important; /* near-black on blue: ~6:1 on #4299e1 */
}
/* Subtle-tint badges: faint background, so the text color must match the tint.
 * Light = darker shade on the pale tint; Dark = Tabler's lighter emphasis shade
 * on the dark tint (near-black failed in dark: ~2:1). */
.badge.bg-danger-subtle.text-danger {
    color: #8a1f1f !important; /* dark red on pale red tint (light) */
}
.badge.bg-success-subtle.text-success {
    color: #14621f !important; /* dark green on pale green tint (light) */
}
[data-bs-theme="dark"] .badge.bg-danger-subtle.text-danger {
    color: #e68282 !important; /* light red on dark red tint */
}
[data-bs-theme="dark"] .badge.bg-success-subtle.text-success {
    color: #82e29a !important; /* light green on dark green tint */
}

/* ponytail: circular loading spinner for ApexCharts boxes.
   Pure CSS — shows immediately (server-rendered container), auto-hides once
   ApexCharts injects its .apexcharts-canvas. No JS, no HTML injection. */
.si-chart-box { position: relative; min-height: 220px; }
.si-chart-spinner {
    position: absolute; top: 50%; left: 50%;
    width: 2rem; height: 2rem; margin: -1rem 0 0 -1rem;
    border: .2em solid var(--tblr-primary);
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: si-chart-spin .75s linear infinite;
    z-index: 1;
}
/* real-child :has() is supported by the engine (proven on dashboard); auto-hide on render */
.si-chart-box:has(.apexcharts-canvas) .si-chart-spinner { display: none; }
@keyframes si-chart-spin { to { transform: rotate(360deg); } }

/* Notes accordion button: Tabler renders .accordion-button at the body's
   heading weight/size, which reads larger than the form-label siblings.
   Match the form-label scale (0.875rem, medium weight) so it sits flush
   with the rest of the invoice form. */
.accordion-button {
    font-size: .875rem;
    font-weight: var(--tblr-font-weight-medium);
}
