.bd-trust-row {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem
}

.bd-trust-row span {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem .72rem;
    border: 1px solid rgb(var(--color-border-strong));
    border-radius: 999px;
    background: rgb(var(--color-surface));
    font-size: .75rem;
    font-weight: 700;
    color: rgb(var(--color-text-muted))
}

.bd-trust-row span:before {
    content: "\2713";
    color: #10b981
}

.bd-app {
    --bd-accent: #2563eb
}

.bd-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem 1.15rem;
    border: 1px solid rgb(var(--color-border-strong));
    border-radius: 1rem;
    background: rgb(var(--color-surface));
    box-shadow: 0 8px 30px rgba(15, 23, 42, .04)
}

.bd-toolbar strong {
    display: block;
    color: rgb(var(--color-text));
    font-size: .95rem
}

.bd-toolbar span {
    display: block;
    color: rgb(var(--color-text-subtle));
    font-size: .75rem;
    margin-top: .15rem
}

.bd-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem
}

.bd-toolbar .tool-button {
    padding: .55rem 1rem;
    font-size: .8rem
}

.bd-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    gap: 1.25rem;
    align-items: start
}

.bd-editor {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0
}

.bd-panel {
    padding: 1.2rem;
    border: 1px solid rgb(var(--color-border-strong));
    border-radius: 1rem;
    background: rgb(var(--color-surface));
    box-shadow: 0 8px 25px rgba(15, 23, 42, .035);
    margin-bottom: 1rem;
}

.bd-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem
}

.bd-panel-heading>div {
    display: flex;
    align-items: center;
    gap: .65rem
}

.bd-panel-heading h2 {
    margin: 0;
    color: rgb(var(--color-text));
    font-size: 1rem;
    font-weight: 800
}

.bd-panel-hint {
    font-size: .7rem;
    color: rgb(var(--color-text-subtle))
}

.bd-step {
    display: grid;
    place-items: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: .55rem;
    background: color-mix(in srgb, var(--bd-accent) 12%, transparent);
    color: var(--bd-accent);
    font-size: .72rem;
    font-weight: 900
}

.bd-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .9rem
}

.bd-span-2 {
    grid-column: span 2
}

.bd-brand-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem
}

.bd-logo-drop {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 88px;
    padding: .8rem;
    border: 1.5px dashed rgb(var(--color-border-strong));
    border-radius: .75rem;
    background: rgb(var(--color-canvas));
    cursor: pointer;
    text-align: center;
    transition: .15s ease
}

.bd-logo-drop:hover {
    border-color: var(--bd-accent);
    background: color-mix(in srgb, var(--bd-accent) 5%, rgb(var(--color-canvas)))
}

.bd-logo-drop strong,
.bd-logo-drop small {
    display: block
}

.bd-logo-drop strong {
    color: rgb(var(--color-text));
    font-size: .82rem
}

.bd-logo-drop small {
    margin-top: .2rem;
    color: rgb(var(--color-text-subtle));
    font-size: .67rem
}

.bd-logo-drop img {
    max-width: 150px;
    max-height: 62px;
    object-fit: contain
}

.bd-text-button {
    margin-top: .35rem;
    padding: 0;
    background: none;
    border: 0;
    color: #e11d48;
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer
}

.bd-color-control {
    display: flex;
    gap: .55rem
}

.bd-color-control input[type=color] {
    width: 3rem;
    height: 2.65rem;
    padding: .18rem;
    border: 1px solid rgb(var(--color-border-strong));
    border-radius: .65rem;
    background: rgb(var(--color-surface));
    cursor: pointer
}

.bd-swatches {
    display: flex;
    gap: .45rem;
    margin-top: .65rem
}

.bd-swatches button {
    width: 1.45rem;
    height: 1.45rem;
    border: 2px solid white;
    border-radius: 999px;
    background: var(--swatch);
    box-shadow: 0 0 0 1px #cbd5e1;
    cursor: pointer
}

.bd-kind-switch {
    display: inline-flex;
    padding: .25rem;
    margin-bottom: 1rem;
    border: 1px solid rgb(var(--color-border-strong));
    border-radius: .7rem;
    background: rgb(var(--color-canvas))
}

.bd-kind-switch button {
    padding: .45rem .85rem;
    border: 0;
    border-radius: .5rem;
    background: transparent;
    color: rgb(var(--color-text-muted));
    font-size: .78rem;
    font-weight: 800;
    cursor: pointer
}

.bd-kind-switch button.active {
    background: rgb(var(--color-surface));
    color: var(--bd-accent);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08)
}

.bd-items-head,
.bd-item-row {
    display: grid;
    grid-template-columns: minmax(150px, 2.6fr) .75fr .6fr .8fr .65fr 32px;
    gap: .45rem;
    align-items: center
}

.bd-items-head {
    padding: 0 .25rem .45rem;
    color: rgb(var(--color-text-subtle));
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em
}

.bd-items {
    display: flex;
    flex-direction: column;
    gap: .55rem
}

.bd-item-row {
    padding: .65rem;
    border: 1px solid rgb(var(--color-border));
    border-radius: .8rem;
    background: rgb(var(--color-canvas))
}

.bd-item-row .tool-input {
    padding: .55rem .6rem;
    font-size: .76rem
}

.bd-remove-item {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: .55rem;
    background: transparent;
    color: #e11d48;
    font-size: 1.1rem;
    cursor: pointer
}

.bd-remove-item:hover {
    background: #fff1f2
}

.bd-preview-panel {
    position: sticky;
    top: 1rem;
    min-width: 0
}

.bd-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .6rem;
    padding: 0 .2rem;
    color: rgb(var(--color-text-muted));
    font-size: .75rem;
    font-weight: 800
}

.bd-preview-toolbar span {
    display: flex;
    align-items: center;
    gap: .4rem
}

.bd-preview-toolbar i {
    width: .5rem;
    height: .5rem;
    border-radius: 999px;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .12)
}

.bd-preview-toolbar button {
    border: 0;
    background: transparent;
    color: rgb(var(--color-text-muted));
    font-weight: 800;
    cursor: pointer
}

.bd-paper-wrap {
    overflow: hidden;
    position: relative
}

.bd-paper {
    width: 680px;
    min-height: 750px;
    padding: 2.55rem;
    background: #fff;
    color: #172033;
    border: 1px solid #e2e8f0;
    border-radius: .55rem;
    box-shadow: 0 18px 55px rgba(15, 23, 42, .12);
    font-family: Arial, sans-serif;
    font-size: .80rem;
    line-height: 1.48;
    overflow: hidden;
    transform-origin: top left
}

.bd-paper-header {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2rem
}

.bd-p-business {
    margin: 0 0 .3rem;
    color: var(--bd-accent);
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .045em
}

.bd-p-muted {
    color: #64748b;
    white-space: pre-line
}

.bd-paper-title-wrap {
    text-align: right
}

#bd-p-logo {
    display: block;
    max-width: 130px;
    max-height: 52px;
    margin: 0 0 .55rem 0;
    object-fit: contain
}

.bd-paper-title-wrap h2 {
    margin: 0 0 .55rem;
    color: var(--bd-accent);
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .045em;
    text-align: right
}

.bd-p-meta {
    display: inline-grid;
    grid-template-columns: auto auto;
    column-gap: 2rem;
    row-gap: .18rem;
    margin: 0;
    text-align: left
}

.bd-p-meta div {
    display: contents
}

.bd-p-meta dt {
    color: #64748b
}

.bd-p-meta dd {
    margin: 0;
    text-align: left;
    font-weight: 800
}

p#bd-p-payment-details {
    color: #94a3b8;
    font-size: .80rem;
    line-height: 1.8;
}

.bd-p-parties {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
    margin-bottom: 1.35rem;
    padding-top: 1rem;
}

.bd-p-parties span,
.bd-p-detail span {
    display: block;
    margin-bottom: .3rem;
    color: #94a3b8;
    font-size: .56rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase
}

.bd-p-parties strong {
    display: block;
    margin-bottom: .22rem;
    font-size: .90rem
}

.bd-p-parties p {
    margin: 0;
    color: #64748b;
    white-space: pre-line
}

.bd-p-scope {
    margin-bottom: 1.15rem;
    padding: .75rem .9rem;
    border-left: 3px solid var(--bd-accent);
    background: #f8fafc;
    color: #475569;
    white-space: pre-line
}

.bd-p-scope p {
    margin: 0
}

.bd-p-table-wrap {
    overflow-x: auto
}

.bd-p-table {
    width: 100%;
    border-collapse: collapse
}

.bd-p-table th {
    padding: .55rem .45rem;
    border-bottom: 2px solid var(--bd-accent);
    color: var(--bd-accent);
    font-size: .56rem;
    text-align: right;
    text-transform: uppercase
}

.bd-p-table th:first-child,
.bd-p-table td:first-child {
    text-align: left
}

.bd-p-table td {
    padding: .6rem .45rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: right;
    vertical-align: top
}

.bd-p-table tbody tr:nth-child(odd) {
    background: #f8fafc
}

.bd-p-empty {
    text-align: center !important;
    color: #94a3b8;
    padding: 1.5rem !important
}

.bd-p-bottom {
    display: grid;
    grid-template-columns: 1fr minmax(200px, .72fr);
    gap: 1.6rem;
    margin-top: 1.25rem
}

.bd-p-detail {
    margin-bottom: 1.2rem
}

.bd-p-detail p {
    margin: 0;
    color: #64748b;
    white-space: pre-line
}

.bd-p-totals {
    margin: 0
}

.bd-p-totals div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .25rem 0
}

.bd-p-totals dt {
    color: #64748b
}

.bd-p-totals dd {
    margin: 0;
    font-weight: 800
}

.bd-p-totals .bd-p-total {
    margin-top: .35rem;
    padding-top: .55rem;
    border-top: 2px solid var(--bd-accent);
    color: var(--bd-accent);
    font-size: .88rem;
    font-weight: 900
}

.bd-p-totals .bd-p-total dt {
    color: var(--bd-accent)
}

.bd-p-totals .bd-p-balance {
    margin-top: .3rem;
    padding-top: .45rem;
    border-top: 1px solid #cbd5e1;
    font-weight: 900
}

.bd-paper footer {
    margin-top: 2.5rem;
    padding-top: .55rem;
    border-top: 1px solid #e2e8f0;
    color: #94a3b8;
    font-size: .58rem;
    text-align: center
}

.bd-download-wide {
    width: 100%;
    margin-top: .8rem
}

.bd-message {
    margin-bottom: 1rem;
    padding: .75rem 1rem;
    border: 1px solid #fecaca;
    border-radius: .8rem;
    background: #fff1f2;
    color: #be123c;
    font-size: .8rem;
    font-weight: 700
}

.bd-message.success {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #047857
}

.bd-mobile-tabs {
    display: none
}

@media(max-width:1120px) {
    .bd-workspace {
        grid-template-columns: 1fr
    }

    .bd-preview-panel {
        position: relative;
        top: auto
    }

    .bd-paper {
        max-width: 760px;
        margin: 0 auto
    }

    .bd-download-wide {
        max-width: 760px;
        margin: .8rem auto 0
    }

    .bd-mobile-tabs {
        display: flex;
        margin: 0 0 .8rem;
        padding: .25rem;
        border: 1px solid rgb(var(--color-border-strong));
        border-radius: .8rem;
        background: rgb(var(--color-surface))
    }

    .bd-view-btn {
        flex: 1;
        padding: .6rem;
        border: 0;
        border-radius: .6rem;
        background: transparent;
        color: rgb(var(--color-text-muted));
        font-weight: 800
    }

    .bd-view-btn.active {
        background: rgb(var(--color-text));
        color: white
    }

    .bd-app[data-mobile-view=editor] .bd-preview-panel {
        display: none
    }

    .bd-app[data-mobile-view=preview] .bd-editor {
        display: none
    }
}

@media(min-width:1121px) {

    .bd-editor,
    .bd-preview-panel {
        display: block !important
    }
}

@media(max-width:640px) {
    .bd-toolbar {
        align-items: flex-start;
        flex-direction: column
    }

    .bd-toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: .45rem
    }

    .bd-toolbar-actions .tool-button {
        padding: .5rem .35rem;
        font-size: .72rem
    }

    .bd-form-grid,
    .bd-brand-grid {
        grid-template-columns: 1fr
    }

    .bd-span-2 {
        grid-column: span 1
    }

    .bd-items-head {
        display: none
    }

    .bd-item-row {
        grid-template-columns: 1fr 1fr
    }

    .bd-item-row [data-field=description] {
        grid-column: span 2
    }

    .bd-remove-item {
        justify-self: end
    }

    .bd-paper {
        min-height: 620px;
        padding: 1.35rem;
        font-size: .65rem
    }

    .bd-paper-header {
        gap: 1rem
    }

    .bd-paper-title-wrap h2 {
        font-size: 1.25rem
    }

    .bd-p-parties {
        grid-template-columns: 1fr 1fr
    }

    .bd-p-parties>div:last-child:nth-child(3) {
        grid-column: span 2
    }

    .bd-p-bottom {
        grid-template-columns: 1fr
    }

    .bd-panel-hint {
        display: none
    }
}

@media print {
    body * {
        visibility: hidden !important
    }

    #bd-paper-wrap,
    #bd-paper,
    #bd-paper * {
        visibility: visible !important
    }

    #bd-paper-wrap {
        overflow: visible;
        height: auto !important
    }

    #bd-paper {
        position: absolute;
        inset: 0;
        width: 100%;
        min-height: 0;
        border: 0;
        box-shadow: none;
        border-radius: 0;
        transform: none !important
    }

    .bd-paper footer {
        display: none
    }
}