.sp-offer-edit-root {
    --sp-offer-catalog-width: 320px;
    --sp-offer-grid-gap: 6px;
    --sp-offer-col-position: 620px;
    --sp-offer-col-qty: 68px;
    --sp-offer-col-unit: 54px;
    --sp-offer-col-days: 66px;
    --sp-offer-col-mode: 116px;
    --sp-offer-col-price: 94px;
    --sp-offer-col-discount: 72px;
    --sp-offer-col-total: 104px;
    --sp-offer-col-actions: 52px;
    min-width: 0;
}

.sp-offer-structure-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, .24);
    background: #fff;
}

.sp-offer-structure-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: min(100%, 580px);
}

.sp-offer-structure-toolbar-actions .form-select {
    min-width: 260px;
}

/* =========================================================
   Katalog | Splitter | Dokument
   ========================================================= */
.sp-offer-editor-grid {
    display: grid;
    grid-template-columns: minmax(250px, var(--sp-offer-catalog-width)) 12px minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
    min-width: 0;
}

.sp-offer-catalog-pane,
.sp-offer-position-workspace {
    min-width: 0;
}

.sp-offer-catalog-pane {
    border: 1px solid rgba(148, 163, 184, .22);
    background: #fff;
}

.sp-offer-catalog-pane-header,
.sp-offer-position-workspace-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, .20);
    background: #f8fafc;
}

.sp-offer-catalog-pane-body {
    max-height: calc(100vh - 190px);
    overflow: auto;
    padding: 8px;
}

.sp-offer-catalog-pane .accordion-item {
    border: 0;
    background: transparent;
}

.sp-offer-catalog-pane .accordion-button {
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 0;
    box-shadow: none;
    background: #f8fafc;
    font-size: .92rem;
    font-weight: 600;
}

.sp-offer-catalog-pane .accordion-button:not(.collapsed) {
    background: #eef3fb;
}

.sp-offer-editor-splitter {
    position: relative;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    min-height: 360px;
}

.sp-offer-editor-splitter::before {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: rgba(148, 163, 184, .70);
}

.sp-offer-editor-splitter > span::after {
    content: "⋮";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 9px 2px;
    border: 1px solid rgba(148, 163, 184, .35);
    background: #f8fafc;
    color: #64748b;
    line-height: 1;
}

.sp-offer-editor-splitter:hover::before,
.sp-offer-editor-splitter.is-dragging::before,
.sp-offer-editor-splitter:focus-visible::before {
    background: rgba(var(--bs-primary-rgb), .82);
}

body.sp-offer-splitter-dragging {
    cursor: col-resize !important;
    user-select: none !important;
}

/* =========================================================
   Katalogbaum
   ========================================================= */
.sp-offer-catalog-tree,
.sp-offer-catalog-children,
.sp-offer-position-tree,
.sp-offer-position-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sp-offer-catalog-children {
    display: none;
    padding-left: 14px;
}

.sp-offer-catalog-children.is-open {
    display: block;
}

.sp-offer-catalog-row {
    display: grid;
    grid-template-columns: 20px 18px minmax(0, 1fr) auto 26px;
    gap: 4px;
    align-items: center;
    min-height: 30px;
    padding: 3px 4px;
    cursor: grab;
    user-select: none;
}

.sp-offer-catalog-row:hover {
    background: rgba(var(--bs-primary-rgb), .055);
}

.sp-offer-catalog-row.is-structure-only {
    cursor: default;
}

.sp-offer-catalog-node.is-open > .sp-offer-catalog-row {
    background: rgba(var(--bs-primary-rgb), .08);
}

.sp-offer-catalog-node.is-subproject > .sp-offer-catalog-row {
    margin-top: 3px;
    border-top: 1px solid rgba(148, 163, 184, .22);
    background: #f8fafc;
    font-weight: 700;
}

.sp-offer-catalog-toggle {
    width: 20px;
    height: 24px;
    border: 0;
    background: transparent;
    padding: 0;
}

.sp-offer-catalog-toggle.is-empty {
    pointer-events: none;
}

.sp-offer-catalog-icon {
    width: 18px;
    text-align: center;
    color: #64748b;
    font-size: .76rem;
}

.sp-offer-catalog-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-offer-catalog-stock,
.sp-offer-catalog-auto {
    white-space: nowrap;
    font-size: .72rem;
    color: #047857;
}

.sp-offer-catalog-stock.is-empty {
    color: #b42318;
    font-weight: 700;
}

.sp-offer-catalog-auto {
    color: #64748b;
    padding: 1px 5px;
    border: 1px solid rgba(148, 163, 184, .28);
}

.sp-offer-catalog-add {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--bs-primary);
    font-size: 1.05rem;
    line-height: 1;
}

.sp-offer-catalog-add:hover {
    background: rgba(var(--bs-primary-rgb), .10);
}

/* =========================================================
   Weißes Positionsblatt
   ========================================================= */
.sp-offer-position-workspace {
    border: 1px solid rgba(148, 163, 184, .20);
    background: #fff;
}

.sp-offer-position-canvas {
    overflow: auto;
    max-height: calc(100vh - 190px);
    min-height: 460px;
    padding: 18px;
    background: #eef2f7;
}

.sp-offer-position-sheet {
    display: inline-block;
    width: max-content;
    min-width: 1260px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, .20);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
    text-align: left;
}

.sp-offer-position-header,
.sp-offer-position-row {
    display: grid;
    grid-template-columns:
        var(--sp-offer-col-position)
        var(--sp-offer-col-qty)
        var(--sp-offer-col-unit)
        var(--sp-offer-col-days)
        var(--sp-offer-col-mode)
        var(--sp-offer-col-price)
        var(--sp-offer-col-discount)
        var(--sp-offer-col-total)
        var(--sp-offer-col-actions);
    gap: var(--sp-offer-grid-gap);
    align-items: center;
}

.sp-offer-position-header {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 38px;
    padding: 7px 9px;
    border-bottom: 1px solid rgba(148, 163, 184, .26);
    background: #f8fafc;
    color: #64748b;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.sp-offer-position-header .is-right {
    text-align: right;
}

.sp-offer-position-sheet-body {
    min-height: 390px;
    padding: 5px 8px 24px;
}

.sp-offer-document-tree,
.sp-offer-position-tree,
.sp-offer-position-children {
    min-width: 0;
}

.sp-offer-position-node {
    margin: 0;
    padding: 0;
}

.sp-offer-position-row {
    position: relative;
    min-height: 27px;
    padding: 1px 3px;
    border: 0;
    background: transparent;
}

.sp-offer-position-row:hover {
    background: rgba(var(--bs-primary-rgb), .035);
}

.sp-offer-position-row.is-structure {
    min-height: 30px;
}

.sp-offer-position-row.is-strong {
    margin-top: 2px;
    background: rgba(241, 245, 249, .62);
}

.sp-offer-position-row.drop-before::before,
.sp-offer-position-row.drop-after::after {
    content: "";
    position: absolute;
    z-index: 15;
    left: 3px;
    right: 3px;
    height: 3px;
    background: var(--bs-primary);
    pointer-events: none;
}

.sp-offer-position-row.drop-before::before { top: -2px; }
.sp-offer-position-row.drop-after::after { bottom: -2px; }

.sp-offer-position-row.drop-into {
    background: rgba(var(--bs-primary-rgb), .10);
    outline: 1px solid rgba(var(--bs-primary-rgb), .35);
}

.sp-offer-position-left {
    display: grid;
    grid-template-columns: 18px 18px 34px minmax(0, 1fr) 20px;
    gap: 4px;
    align-items: center;
    min-width: 0;
}

.sp-offer-position-children {
    display: block;
}

.sp-offer-position-children:not(.is-open) {
    display: none;
}

.sp-offer-position-tree > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-row > .sp-offer-position-left { padding-left: 18px; }
.sp-offer-position-tree > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-row > .sp-offer-position-left { padding-left: 36px; }
.sp-offer-position-tree > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-row > .sp-offer-position-left { padding-left: 54px; }
.sp-offer-position-tree > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-children > .sp-offer-position-node > .sp-offer-position-row > .sp-offer-position-left { padding-left: 72px; }

.sp-offer-position-handle,
.sp-offer-position-toggle,
.sp-offer-position-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 20px;
    border: 0;
    padding: 0;
    background: transparent;
    color: #64748b;
}

.sp-offer-position-handle {
    cursor: grab;
    user-select: none;
}

.sp-offer-position-handle.is-disabled {
    cursor: default;
}

.sp-offer-position-toggle.is-empty {
    visibility: hidden;
}

.sp-offer-position-number {
    min-width: 34px;
    text-align: right;
    color: #94a3b8;
    font-size: .73rem;
}

.sp-offer-position-title-input,
.sp-offer-position-cell input,
.sp-offer-position-cell select,
.sp-offer-position-details textarea,
.sp-offer-position-details input,
.sp-offer-position-details select {
    width: 100%;
    min-width: 0;
    height: 24px;
    padding: 1px 4px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    box-shadow: none;
    color: #0f172a;
    font-size: .86rem;
    line-height: 1.15;
}

textarea.sp-offer-position-title-input {
    height: 27px;
    resize: vertical;
    overflow: hidden;
}

.sp-offer-position-title-input:hover,
.sp-offer-position-cell input:hover,
.sp-offer-position-cell select:hover {
    background: #f8fafc;
}

.sp-offer-position-title-input:focus,
.sp-offer-position-cell input:focus,
.sp-offer-position-cell select:focus,
.sp-offer-position-details textarea:focus,
.sp-offer-position-details input:focus,
.sp-offer-position-details select:focus {
    outline: 0;
    border-color: rgba(var(--bs-primary-rgb), .35);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .08);
}

.sp-offer-position-title-input:disabled,
.sp-offer-position-cell input:disabled,
.sp-offer-position-cell select:disabled {
    opacity: 1;
    color: #334155;
}

.sp-offer-position-title-input.is-strong {
    font-weight: 750;
}

.sp-offer-position-title-input.is-text {
    font-style: italic;
    color: #475569;
}

.sp-offer-position-cell.is-number input,
.sp-offer-position-cell.is-money input {
    text-align: right;
}

.sp-offer-position-cell.is-total {
    position: relative;
}

.sp-offer-position-cell.is-total input {
    padding-right: 20px;
    font-weight: 700;
}

.sp-offer-position-cell input.is-manual {
    background: #fff8e1;
    border-color: rgba(245, 158, 11, .45);
}

.sp-offer-total-reset {
    position: absolute;
    top: 2px;
    right: 1px;
    width: 19px;
    height: 19px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #64748b;
}

.sp-offer-position-structure-spacer {
    grid-column: 2 / 8;
}

.sp-offer-position-structure-total {
    grid-column: 8;
    text-align: right;
    font-weight: 700;
    font-size: .86rem;
}

.sp-offer-position-actions {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
}

.sp-offer-position-action {
    font-size: .95rem;
}

.sp-offer-position-action:hover {
    background: rgba(var(--bs-primary-rgb), .09);
}

.sp-offer-position-action.is-delete {
    color: #b42318;
}

.sp-offer-position-availability {
    min-width: 20px;
    text-align: center;
}

.sp-offer-availability-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 800;
}

.sp-offer-availability-icon.is-ok { color: #047857; background: #d1fae5; }
.sp-offer-availability-icon.is-bad { color: #b42318; background: #fee2e2; }
.sp-offer-availability-icon.is-warning { color: #92400e; background: #fef3c7; }
.sp-offer-availability-icon.is-neutral { color: #475569; background: #e2e8f0; }

.sp-offer-position-details {
    margin: 2px 56px 5px 74px;
    padding: 8px 10px;
    border-left: 2px solid rgba(var(--bs-primary-rgb), .18);
    background: #f8fafc;
}

.sp-offer-position-details[hidden] {
    display: none !important;
}

.sp-offer-position-details textarea {
    min-height: 48px;
    height: auto;
    resize: vertical;
    border-color: rgba(148, 163, 184, .25);
    background: #fff;
}

.sp-offer-position-detail-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 8px;
    margin-top: 7px;
}

.sp-offer-position-detail-fields label {
    min-width: 210px;
    margin: 0;
    color: #64748b;
    font-size: .74rem;
}

.sp-offer-position-detail-fields label > span {
    display: block;
    margin-bottom: 2px;
}

.sp-offer-position-detail-fields .is-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: auto;
    padding-bottom: 3px;
}

.sp-offer-position-detail-fields .is-checkbox input {
    width: auto;
    height: auto;
}

.sp-offer-position-child-drop {
    height: 6px;
    margin: 0 6px 0 72px;
}

.sp-offer-position-child-drop.is-over {
    height: 18px;
    background: rgba(var(--bs-primary-rgb), .09);
    outline: 1px dashed rgba(var(--bs-primary-rgb), .55);
}

/* =========================================================
   Subprojekte als oberste Dokumentknoten
   ========================================================= */
.sp-offer-subproject-root-drop,
.sp-offer-root-drop,
.sp-offer-subproject-position-drop {
    min-height: 28px;
    margin: 4px 3px;
    padding: 5px 10px;
    border: 1px dashed rgba(148, 163, 184, .34);
    color: #64748b;
    text-align: center;
    font-size: .76rem;
}

.sp-offer-subproject-root-drop.is-over,
.sp-offer-root-drop.is-over,
.sp-offer-subproject-position-drop.is-over {
    border-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), .08);
    color: var(--bs-primary);
}

.is-locked.sp-offer-subproject-root-drop,
.is-locked.sp-offer-root-drop,
.is-locked.sp-offer-subproject-position-drop {
    display: none;
}

.sp-offer-subproject-node {
    position: relative;
    margin: 8px 0 16px;
}

.sp-offer-subproject-drop-line {
    height: 5px;
}

.sp-offer-subproject-drop-line.is-over {
    height: 9px;
    background: var(--bs-primary);
}

.sp-offer-subproject-heading {
    display: grid;
    grid-template-columns: 18px 18px 58px minmax(180px, .8fr) minmax(280px, 1.6fr) auto 24px;
    gap: 6px;
    align-items: center;
    min-height: 38px;
    padding: 5px 7px;
    border-top: 2px solid #334155;
    border-bottom: 1px solid #cbd5e1;
    background: #f1f5f9;
    cursor: default;
}

.sp-offer-subproject-heading.is-active {
    background: #eaf1ff;
    border-top-color: var(--bs-primary);
}

.sp-offer-subproject-heading.drop-before::before,
.sp-offer-subproject-heading.drop-after::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bs-primary);
}

.sp-offer-subproject-handle {
    cursor: grab;
    color: #64748b;
}

.sp-offer-subproject-handle.is-disabled {
    cursor: default;
}

.sp-offer-subproject-toggle {
    width: 18px;
    height: 20px;
    padding: 0;
    border: 0;
    background: transparent;
}

.sp-offer-subproject-number {
    color: #475569;
    font-size: .73rem;
    font-weight: 800;
    letter-spacing: .03em;
}

.sp-offer-subproject-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #0f172a;
    font-weight: 800;
}

.sp-offer-subproject-meta {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #64748b;
    font-size: .73rem;
}

.sp-offer-subproject-edit-button,
.sp-offer-subproject-delete-button {
    padding: 0 4px;
    text-decoration: none;
    white-space: nowrap;
}

.sp-offer-subproject-editor {
    padding: 10px 12px;
    border-bottom: 1px solid #cbd5e1;
    background: #f8fafc;
}

.sp-offer-subproject-editor-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(145px, 1fr));
    gap: 8px;
}

.sp-offer-subproject-field label {
    display: block;
    margin-bottom: 2px;
    color: #64748b;
    font-size: .72rem;
}

.sp-offer-subproject-field.is-wide { grid-column: span 2; }
.sp-offer-subproject-field.is-full { grid-column: 1 / -1; }

.sp-offer-subproject-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 9px;
}

.sp-offer-subproject-content:not(.is-open) {
    display: none;
}

.sp-offer-subproject-position-drop {
    margin: 5px 7px 2px 32px;
}

.sp-offer-unassigned-block {
    margin-top: 18px;
    border: 1px solid #f59e0b;
    background: #fffbeb;
}

.sp-offer-unassigned-title {
    padding: 7px 10px;
    border-bottom: 1px solid #fcd34d;
    font-weight: 700;
}

.sp-offer-unassigned-title span {
    margin-left: 8px;
    color: #92400e;
    font-size: .76rem;
    font-weight: 400;
}

/* =========================================================
   Summenblock
   ========================================================= */
.sp-offer-summary-below {
    padding: 14px;
    border-top: 1px solid rgba(148, 163, 184, .20);
    background: #fff;
}

.sp-offer-summary-below .card,
.sp-offer-summary-below .sp-offer-summary-card {
    border-radius: 0;
    box-shadow: none;
}

@media (max-width: 1100px) {
    .sp-offer-editor-grid {
        grid-template-columns: 1fr;
    }

    .sp-offer-editor-splitter {
        display: none;
    }

    .sp-offer-catalog-pane-body {
        max-height: 390px;
    }

    .sp-offer-position-canvas {
        max-height: 720px;
    }

    .sp-offer-structure-toolbar,
    .sp-offer-structure-toolbar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .sp-offer-structure-toolbar-actions .form-select {
        min-width: 0;
    }
}

@media (max-width: 760px) {
    .sp-offer-subproject-editor-grid {
        grid-template-columns: 1fr;
    }

    .sp-offer-subproject-field.is-wide,
    .sp-offer-subproject-field.is-full {
        grid-column: auto;
    }
}
