.treeselect-input {
    width: 100%;
    height: 42px;
    box-sizing: border-box;
    border-radius: 4px;
    display: flex;
    align-items: center;
    position: relative;
    background-color: rgb(var(--input-bg));
    cursor: text;
    border-radius: 0;
    overflow: hidden;
}

/* Background label - always visible, changes position and color based on state */
.treeselect-input::before {
    content: attr(data-label);
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    pointer-events: none;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* font-family: var(--font-compact); */
    font-size: 1.1rem;
    font-weight: 300;
    color: rgb(var(--grey-400));
    text-transform: uppercase;
    /* letter-spacing: 0.1em; */
    line-height: 1;
    transition: transform .7s cubic-bezier(.25, .46, .45, .94),
                color .7s cubic-bezier(.25, .46, .45, .94),
                font-size .7s cubic-bezier(.25, .46, .45, .94),
                opacity .7s cubic-bezier(.25, .46, .45, .94);
    transform: translateX(0);
    /* opacity: 0.4; */
}


/* When chips are present - move to right, make lighter and larger, hide input */
.treeselect-input:has(.treeselect-input__tags-element)::before {
    transform: translateX(25%);
    font-size: 1.5rem;
    opacity: 0;
    right: 0.7em;
}

.treeselect-input:has(.treeselect-input__tags-element) .treeselect-input__edit {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.treeselect-input:hover {
    background-color: rgb(var(--input-bg-hover)) !important;
    transform: scale(1.02);
}

.treeselect-input--unsearchable {
    cursor: default
}

.treeselect-input--unsearchable .treeselect-input__edit {
    caret-color: transparent;
    cursor: default
}

.treeselect-input--unsearchable .treeselect-input__edit:focus {
    position: absolute;
    z-index: -1;
    left: 0;
    min-width: 0;
    width: 0
}

.treeselect-input--value-not-selected .treeselect-input__edit,
.treeselect-input--value-not-selected.treeselect-input--unsearchable .treeselect-input__edit:focus {
    z-index: -1;
    position: absolute;
    width: 0;
    max-width: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.treeselect-input--value-not-selected .treeselect-input__tags {
    gap: 0;
}

[dir=rtl] .treeselect-input {
    padding-right: 4px;
    padding-left: 40px
}

[dir=rtl] .treeselect-input__operators {
    right: unset;
    left: 2px
}

.treeselect-input__tags {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: no-wrap;
    gap: 4px;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.treeselect-input__tags-element {
    display: inline-flex;
    align-items: center;
    background-color: rgba(var(--color-primary-active), 0.3);
    cursor: pointer;
    padding: 4px 6px;
    font-size: 16px;
    /* font-family: var(--font-compact); */
    box-sizing: border-box;
    position: relative;
    z-index: 2;
    color: rgb(var(--grey-800));
}

.treeselect-input__tags-element:hover {
    background-color: rgba(var(--color-primary-hover), 0.25);
}

.treeselect-input__tags-element:hover .treeselect-input__tags-cross svg {
    stroke: rgb(var(--color-error));
}

.treeselect-input__tags-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
    line-height: 1.2;
}

.treeselect-input__tags-cross {
    display: none;
    margin-left: 2px
}

.treeselect-input__tags-cross svg {
    width: 12px;
    height: 12px
}

.treeselect-input__tags-count {
    font-size: 16px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis
}

.treeselect-input__edit {
    flex: 1;
    border: none;
    font-size: 0.9em;
    text-overflow: ellipsis;
    width: 100%;
    max-width: calc(100% - 45px);
    padding: 0;
    position: absolute;
    z-index: -1;
    min-width: 0;
    background: transparent;
}

.treeselect-input__edit:focus {
    outline: none;
    min-width: 30px;
    max-width: 100%;
    z-index: auto;
    position: static
}

.treeselect-input__operators {
    display: flex;
    max-width: 50px;
    height: 43px;
    background: inherit;
    z-index: 1;
}

.treeselect-input__clear {
    display: flex;
    cursor: pointer
}

.treeselect-input__clear svg {
    stroke: rgb(var(--grey-400));
    width: 17px;
    min-width: 17px;
    height: 20px
}

.treeselect-input__clear:hover svg {
    stroke: rgb(var(--grey-500))
}

.treeselect-input__arrow {
    display: flex;
    cursor: pointer;
    margin: 0 3px;
    align-self: center;
}

.treeselect-input__arrow svg {
    stroke: rgb(var(--grey-400));
    width: 20px;
    min-width: 20px;
    height: 20px
}

.treeselect-input__arrow:hover svg {
    stroke: rgb(var(--grey-500))
}

.treeselect-list {
    min-width: 100%;
    box-sizing: border-box;
    border: 1px solid rgb(var(--grey-300));
    overflow-y: auto;
    background-color: rgb(var(--color-canvas));
    max-height: 300px;
    position: absolute;
    left: 0;
    border-radius: 4px;
    box-sizing: border-box;
    z-index: 1095; /* Выше search-line (1020) и табов */
    /* transition: max-height .15s ease-out, opacity .15s ease-out, transform .15s ease-out; */
}

/* Dark mode dropdown border - инверсия через токены */

.treeselect-list__group-container {
    box-sizing: border-box
}

.treeselect-list__item {
    z-index: inherit; /* Наследует от .treeselect-list */
    display: flex;
    align-items: center;
    box-sizing: border-box;
    cursor: pointer;
    height: 30px
}

.treeselect-list__item:focus {
    outline: none
}

.treeselect-list__item--focused:not(.treeselect-list__item--disabled) {
    background-color: rgba(var(--color-primary-hover), 0.15) !important;
}

.treeselect-list__item--hidden {
    display: none
}

.treeselect-list__item-icon {
    display: flex;
    align-items: center;
    cursor: pointer;
    height: 20px;
    width: 20px;
    min-width: 20px
}

.treeselect-list__item-icon svg {
    pointer-events: none;
    width: 100%;
    height: 100%;
    stroke: rgb(var(--grey-400))
}

.treeselect-list__item-icon * {
    pointer-events: none
}

.treeselect-list__item-icon:hover svg {
    stroke: rgb(var(--grey-500))
}

.treeselect-list__item-checkbox-container {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 1px solid rgb(var(--grey-300));
    border-radius: 3px;
    position: relative;
    background-color: rgb(var(--color-canvas));
    pointer-events: none;
    box-sizing: border-box
}

/* Dark mode checkbox border - инверсия через токены */

.treeselect-list__item-checkbox-container svg {
    position: absolute;
    height: 100%;
    width: 100%
}

.treeselect-list__item-checkbox {
    margin: 0;
    width: 0;
    height: 0;
    pointer-events: none;
    position: absolute;
    z-index: -1
}

.treeselect-list__item-checkbox-icon {
    position: absolute;
    height: 100%;
    width: 100%;
    left: 0;
    top: 0;
    text-align: left
}

.treeselect-list__item-label {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: keep-all;
    white-space: nowrap;
    font-size: 16px;
    padding-left: 5px;
    pointer-events: none;
    text-align: left;
    padding-right:5px;
    /* font-family: var(--font-compact); */
    letter-spacing: 0.015em;
    font-weight: 500;
    color: rgb(var(--grey-600));
}

/* Dark mode элементы списка - инверсия через токены */

.treeselect-list__item-label-counter {
    margin-left: 3px;
    color: rgb(var(--grey-500));
    font-size: 13px
}

.treeselect-list__empty {
    display: flex;
    align-items: center;
    height: 30px;
    padding-left: 4px
}

.treeselect-list__empty--hidden {
    display: none
}

.treeselect-list__empty-icon {
    display: flex;
    align-items: center
}

.treeselect-list__empty-text {
    font-size: 16px;
    padding-left: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: keep-all;
    white-space: nowrap
}

.treeselect-list__slot {
    position: sticky;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    bottom: 0;
    background-color: rgb(var(--color-canvas))
}

.treeselect-list.treeselect-list--single-select .treeselect-list__item-checkbox-container,
.treeselect-list.treeselect-list--disabled-branch-node .treeselect-list__item--group .treeselect-list__item-checkbox-container {
    display: none
}

.treeselect-list__item--checked {
    background-color: rgb(var(--color-canvas));
    background-image: linear-gradient(135deg, rgba(var(--color-primary-hover), 0.2), rgba(var(--color-primary-hover), 0.15));
}

.treeselect-list.treeselect-list--single-select .treeselect-list__item--checked {
    background-color: transparent
}

.treeselect-list.treeselect-list--single-select .treeselect-list__item--single-selected {
    background-color: rgb(var(--color-canvas));
    background-image: linear-gradient(135deg, rgba(var(--color-primary-hover), 0.2), rgba(var(--color-primary-hover), 0.15));
}

.treeselect-list__item .treeselect-list__item-checkbox-container svg {
    stroke: transparent
}

.treeselect-list__item--checked .treeselect-list__item-checkbox-container svg,
.treeselect-list__item--partial-checked .treeselect-list__item-checkbox-container svg {
    stroke: rgb(var(--grey-800));
    fill: rgb(var(--grey-800));
}

.treeselect-list__item--checked .treeselect-list__item-checkbox-container,
.treeselect-list__item--partial-checked .treeselect-list__item-checkbox-container {
    background-color: rgb(var(--color-canvas));
    border-color: rgb(var(--grey-300));
}

/* Dark mode treeselect checkmarks - инверсия через токены */

.treeselect-list__item--disabled, .treeselect-list__item--disabled .treeselect-list__item-checkbox-container {
    background-color: rgb(var(--input-disabled-bg))
}

.treeselect-list__item--disabled .treeselect-list__item-label {
    color: rgb(var(--input-disabled-text))
}

.treeselect-list__item--checked.treeselect-list__item--disabled .treeselect-list__item-checkbox-container,
.treeselect-list__item--partial-checked .treeselect-list__item-checkbox-container {
    background-color: rgb(var(--color-warning))
}

/* Dark mode disabled элементы - инверсия через токены */

.treeselect {
    position: relative;
    box-sizing: border-box;
    z-index: 1090; /* Выше табов и search-line */
}

.treeselect--disabled {
    pointer-events: none
}

.treeselect .treeselect-list {
    position: absolute;
    z-index: 1095; /* Еще выше для dropdown */
}

.treeselect .treeselect-list--static {
    position: static
}

.treeselect-input--opened.treeselect-input--top {
    border-top-color: transparent;
    border-top-left-radius: 0;
    border-top-right-radius: 0
}

.treeselect-input--opened.treeselect-input--bottom {
    border-bottom-color: transparent;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0
}

.treeselect-list--top,
.treeselect-list--top-to-body {
    border-bottom-color: rgb(var(--grey-300));
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0
}

.treeselect-list--bottom,
.treeselect-list--bottom-to-body {
    border-top-color: rgb(var(--grey-300));
    border-radius: 0;
}

.treeselect-list--top {
    left: 0;
    bottom: 100%
}

.treeselect-list--bottom {
    left: 0;
    top: 100%
}