.nf-search-panel,
.nf-filter,
.nf-filter * {
    box-sizing: border-box;
}

.nf-search-panel {
    width: 100%;
    min-height: 58px;
    margin: 0 0 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #1a1a1a;
}

.nf-search-panel__input {
    width: 100%;
    height: 40px;
    padding: 8px 12px;
    color: #fff;
    font-size: 13px;
    background: #2d2d2d;
    border: 1px solid #ff8c00;
    border-radius: 6px;
}

.nf-search-panel__input:focus {
    outline: 0;
    border-color: #ffaa33;
    background: #333;
}

.nf-search-panel__stats {
    display: none;
    margin-top: 8px;
    padding: 6px 10px;
    color: #ffaa66;
    font-size: 12px;
    background: #2d2d2d;
    border-left: 3px solid #ff8c00;
    border-radius: 6px;
}

.nf-search-panel__stats.is-visible {
    display: block;
}

.nf-filter {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    align-items: start;
}

.nf-filter__guide,
.nf-filter__match,
.nf-filter__summary,
.nf-filter .fb-submit {
    grid-column: 1 / -1;
}

.nf-filter__guide {
    min-height: 42px;
    padding: 9px 12px;
    color: #d7d7d7;
    font-size: 13px;
    line-height: 22px;
    background: #222;
    border: 1px solid #3b3b3b;
    border-radius: 8px;
}

.nf-filter__guide-title {
    color: #f0f0f0;
    font-weight: 700;
    cursor: pointer;
}

.nf-filter__guide-title:focus-visible {
    outline: 2px solid #ff8c00;
    outline-offset: 3px;
}

.nf-filter__guide-body {
    display: grid;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #3b3b3b;
}

.nf-filter__guide-sign {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin: 0 3px;
    font-weight: 700;
    border-radius: 5px;
}

.nf-filter__guide-sign--include {
    color: #1f8c4c;
    background: #e7f8ee;
}

.nf-filter__guide-sign--exclude {
    color: #bd3030;
    background: #fdeaea;
}

.nf-filter__match {
    display: flex;
    align-items: center;
    gap: 8px 12px;
    min-height: 46px;
    padding: 7px 10px;
    color: #d7d7d7;
    font-size: 12px;
    background: #181818;
    border: 1px solid #333;
    border-radius: 8px;
}

.nf-filter__match-label {
    flex: 0 0 auto;
    font-weight: 700;
}

.nf-filter__match-options {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 3px;
    padding: 3px;
    background: #101010;
    border-radius: 7px;
}

.nf-filter__match-button {
    min-height: 30px;
    padding: 5px 10px;
    color: #ccc;
    font: inherit;
    font-weight: 600;
    background: #2a2a2a;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
}

.nf-filter__match-button:hover,
.nf-filter__match-button:focus-visible {
    color: #fff;
    border-color: #777;
    outline: 0;
}

.nf-filter__match-button.is-active {
    color: #111;
    background: #ff9b21;
    border-color: #ffad49;
}

.nf-filter__match-hint {
    min-width: 0;
    color: #aaa;
    line-height: 16px;
}

.nf-filter__summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    height: 70px;
    min-height: 70px;
    padding: 8px;
    overflow: hidden;
    background: #181818;
    border: 1px solid #333;
    border-radius: 8px;
}

.nf-filter__summary-group {
    min-width: 0;
    overflow: auto;
    scrollbar-width: thin;
}

.nf-filter__summary-title {
    display: inline-block;
    margin: 0 7px 4px 0;
    color: #aaa;
    font-size: 12px;
    font-weight: 600;
}

.nf-filter__chips {
    display: inline;
}

.nf-filter__empty {
    color: #777;
    font-size: 12px;
}

.nf-filter__chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 24px;
    margin: 0 5px 4px 0;
    padding: 2px 4px 2px 8px;
    color: #1f1f1f;
    font-size: 12px;
    border-radius: 12px;
}

.nf-filter__chip--include {
    background: #dff5e8;
}

.nf-filter__chip--exclude {
    background: #f9dddd;
}

.nf-filter__chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nf-filter__chip-remove {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin-left: 3px;
    padding: 0;
    color: inherit;
    line-height: 18px;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.nf-filter__chip-remove:hover,
.nf-filter__chip-remove:focus-visible {
    background: rgba(0, 0, 0, .12);
}

/* До запуска Tail.Select каждый select занимает ровно одну строку. */
.nf-filter > select {
    display: block;
    width: 100%;
    min-width: 0;
    height: 34px;
    max-height: 34px;
    margin: 0;
    overflow: hidden;
}

/*
 * До запуска Tail.Select браузер показывает первый option каждого multiple-
 * списка как будто это выбранная категория. Скрываем только это временное
 * нативное содержимое, сохраняя точные размеры будущего поля.
 */
.nf-filter > select:not([data-tail-select]) {
    color: transparent !important;
    font-size: 0 !important;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='34' viewBox='0 0 180 34'%3E%3Ctext x='10' y='22' fill='%23666' font-family='Arial,sans-serif' font-size='12' font-weight='700'%3E0%3C/text%3E%3Crect x='34' y='12' width='96' height='10' rx='5' fill='%23e7e7e7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left center;
    background-size: auto 34px;
    border: 0;
    border-radius: 3px;
    box-shadow: 0 1px 1px 1px rgba(0, 0, 0, .1), 0 0 1px 1px rgba(0, 0, 0, .25);
}

.nf-filter > select:not([data-tail-select]) option {
    display: none;
}

.nf-filter > .tail-select {
    width: 100%;
    min-width: 0;
    height: 34px;
    margin: 0;
}

.nf-filter > .tail-select .select-label {
    height: 34px;
}

.nf-filter .tail-select .select-dropdown {
    z-index: 120;
}

.nf-filter .tail-select.open-top .select-dropdown {
    z-index: 121;
}

.nf-filter .dropdown-option.nf-option {
    min-height: 36px;
    padding: 5px 76px 5px 10px;
}

/* Штатный квадрат Tail.Select дублирует наши отдельные кнопки + и −. */
.nf-filter .tail-select.multiple .dropdown-option.nf-option::before {
    display: none !important;
    content: none !important;
    background-image: none !important;
}

.nf-option__label {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nf-option__actions {
    position: absolute;
    top: 4px;
    right: 6px;
    display: flex;
    gap: 4px;
}

.nf-option__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 27px;
    height: 27px;
    padding: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    background: #f3f3f3;
    border: 1px solid #cfcfcf;
    border-radius: 5px;
    cursor: pointer;
}

.nf-option__button--include {
    color: #197441;
}

.nf-option__button--exclude {
    color: #a82b2b;
}

.nf-option__button:hover,
.nf-option__button:focus-visible {
    color: #fff;
    outline: 0;
}

.nf-option__button--include:hover,
.nf-option__button--include:focus-visible,
.nf-option.is-included .nf-option__button--include {
    background: #218c50;
    border-color: #218c50;
    color: #fff;
}

.nf-option__button--exclude:hover,
.nf-option__button--exclude:focus-visible,
.nf-option.is-excluded .nf-option__button--exclude {
    background: #bd3535;
    border-color: #bd3535;
    color: #fff;
}

.nf-option.is-search-match {
    box-shadow: inset 3px 0 0 #ff8c00;
    background: #fff1dd !important;
}

.nf-filter .tail-select.has-search-match > .select-label {
    box-shadow: 0 0 0 2px #ff8c00;
}

@media (max-width: 900px) {
    .nf-filter {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .nf-filter {
        grid-template-columns: minmax(0, 1fr);
    }

    .nf-filter__summary {
        grid-template-columns: minmax(0, 1fr);
        height: 112px;
        min-height: 112px;
    }

    .nf-filter__match {
        align-items: flex-start;
        flex-direction: column;
    }

    .nf-filter__match-options {
        width: 100%;
    }

    .nf-filter__match-button {
        flex: 1 1 50%;
    }
}
