.modal-content:has(.lead-modal-sectioned) {
    width: 640px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* #modal-body is a generic wrapper shared by every modal type (modal.js) —
   it normally has no sizing of its own, so it has to be pulled into the
   flex chain here, scoped to only this modal, or the max-height/overflow
   above has nothing to constrain and just clips content instead of
   scrolling it. */
.modal-content:has(.lead-modal-sectioned) > #modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.lead-modal-sectioned {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.lead-modal-scroll {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.lead-modal-sectioned .modal-footer {
    flex-shrink: 0;
    padding-top: 16px;
}

.lead-modal-sectioned input,
.lead-modal-sectioned select,
.lead-modal-sectioned textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 10px;
    font-family: inherit;
}

.lead-section {
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.lead-section-title {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.lead-essentials {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.avatar-upload {
    width: 72px;
    height: 72px;
    min-width: 72px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    font-size: 28px;
}

.avatar-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lead-essentials-fields {
    flex: 1;
}

.vip-stars {
    display: flex;
    gap: 4px;
    font-size: 22px;
    color: #f59e0b;
    cursor: pointer;
    margin-bottom: 10px;
    user-select: none;
}

.custom-field-row {
    display: block;
    margin-bottom: 10px;
}

.custom-field-row span {
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
}

.lead-field-label {
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
}

.custom-field-image {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-field-image-preview {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: #f3f4f6;
}

.custom-field-image-preview.hidden {
    display: none;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    background: rgba(0, 0, 0, .55);
}

.lead-fields-config {
    max-width: 600px;
}

.lead-field-form {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    align-items: center;
}

.lead-field-form input,
.lead-field-form select {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.contact-method-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
}

.lead-field-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 8px;
}

.lead-field-item span:first-child {
    flex: 1;
    font-weight: 600;
}

.field-type-tag {
    font-size: 12px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 999px;
}

.order-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.order-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    cursor: pointer;
}

.order-item:hover {
    background: #f5f7fb;
}

.order-item-date {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
}

.order-item-products {
    flex: 1;
    font-size: 14px;
}

.order-item-status {
    font-size: 12px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 999px;
}

.order-item-total {
    font-weight: 600;
    white-space: nowrap;
}

.order-modal label {
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-top: 10px;
    margin-bottom: 4px;
}

.order-modal input,
.order-modal select,
.order-modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.order-item-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.order-item-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.order-item-row .order-item-product {
    flex: 2;
}

.order-item-row .order-item-qty {
    flex: 1;
    min-width: 60px;
}

.order-item-row .order-item-price {
    flex: 1;
    min-width: 80px;
}

.order-item-row .order-item-remove {
    flex-shrink: 0;
    padding: 8px 10px;
}

.order-total {
    margin-top: 12px;
    font-weight: 600;
    text-align: right;
}

.order-item-row-readonly {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 14px;
}

.order-item-row-price {
    color: #6b7280;
}

.field-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

.order-row {
    cursor: pointer;
}

.order-row:hover {
    background: #f5f7fb;
}

.product-modal label {
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-top: 10px;
    margin-bottom: 4px;
}

.product-modal input,
.product-modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.product-active-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-direction: row;
}

.product-row {
    cursor: pointer;
}

.product-row:hover {
    background: #f5f7fb;
}

.inventory-stock-input {
    width: 100px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}
