.dk-filter-demo {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.crm-filter-host { width: 100%; min-width: 0; }
.crm-filter-host > [hidden] { display: none; }
.crm-filter-host .dk-filter-popover { position: fixed; z-index: 60; padding: 18px; }
.crm-filter-host .dk-filter-fields { flex: 1; min-height: 0; padding-bottom: 8px; }
.crm-filter-host .dk-filter-actions { position: static; flex-shrink: 0; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.crm-filter-host .dk-filter-actions-left { flex-wrap: wrap; gap: 10px 14px; }
.crm-filter-host .dk-filter-row { flex-shrink: 0; }
.crm-filter-host .dk-search { font-size: 14px; }
.crm-filter-host .dk-search-wrap { z-index: 40; }
.crm-filter-host .dk-layer { max-height: 320px; z-index: 90; }
.crm-filter-host .dk-field-modal { z-index: 100; }
.crm-filter-host .dk-token { border: 1px solid #d8e0ea; border-radius: 999px; background: #fbfcfd; color: #414b56; font-weight: 400; }
.crm-filter-host .dk-drag-handle { opacity: .6; }
.crm-filter-host .dk-filter-row:hover .dk-drag-handle { opacity: 1; }
.crm-filter-host .dk-select-button { white-space: normal; overflow-wrap: anywhere; }
.crm-filter-host .dk-select-button::after { border-width: 1.1px; transform: rotate(45deg) scale(.8, .8); }
.dk-button-black { background: #2a2f33; color: #ffffff; }
.dk-button-black:hover { background: #191b1e; }
.dk-filter-error { color: #b42318; font-size: 12px; margin: 0 0 10px; overflow-wrap: anywhere; }
.dk-options-actions { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin: 10px 4px; }
.dk-options-list { max-height: 220px; overflow: auto; }
.dk-options-list .dk-menu-item { height: auto; padding: 8px 10px; }
.dk-options-list .dk-menu-item span { overflow-wrap: anywhere; min-width: 0; }
.dk-options-list input[type=checkbox] { flex-shrink: 0; }
.dk-options-status { font-size: 12px; color: var(--muted); padding: 8px; }
.dk-options-more { margin: 10px; }
.dk-reference-types { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 4px 10px; }
.dk-reference-types .is-selected { color: var(--text); text-decoration: underline; }
.dk-reference-error { padding: 8px 12px; color: #b42318; background: #fff6f6; border-radius: 8px; }

.dk-filter-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    min-width: 0;
}

.dk-search-wrap {
    position: relative;
    min-width: 0;
}

.dk-search {
    width: 100%;
    height: 36px;
    border: 1px solid var(--input-line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-soft);
    font: 15px/1.2 var(--font);
    outline: none;
    padding: 0 14px;
}

.dk-search:focus,
.dk-search-wrap.is-open .dk-search {
    border-color: #0077ff;
}

.dk-search-chips {
    position: absolute;
    top: 50%;
    left: 9px;
    z-index: 2;
    display: flex;
    max-width: 58%;
    gap: 5px;
    pointer-events: none;
    transform: translateY(-50%);
}

.dk-search-chip {
    display: inline-flex;
    align-items: center;
    max-width: 240px;
    height: 25px;
    border-radius: 6px;
    background: #e6f4ff;
    color: var(--link);
    font-size: 13px;
    line-height: 1;
    padding: 0 8px;
    white-space: nowrap;
}

.dk-search-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.dk-filter-popover {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: min(760px, 100%);
    max-height: min(72vh, 680px);
    border: 1px solid #e5ebf0;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: var(--shadow-menu);
    padding: 18px 18px 74px;
}

.dk-filter-popover[hidden] {
    display: none;
}

.dk-filter-fields {
    display: grid;
    gap: 13px;
    overflow: auto;
    padding: 0 2px 18px;
}

.dk-filter-row {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    min-width: 0;
}

.dk-filter-row.is-draggable {
    padding-left: 20px;
}

.dk-drag-handle {
    position: absolute;
    top: 28px;
    left: 0;
    width: 14px;
    height: 20px;
    cursor: grab;
    opacity: 0;
}

.dk-drag-handle::before {
    content: "";
    display: block;
    width: 3px;
    height: 3px;
    margin: 2px;
    border-radius: 50%;
    background: #9aa3ad;
    box-shadow: 0 6px 0 #9aa3ad, 0 12px 0 #9aa3ad, 6px 0 0 #9aa3ad, 6px 6px 0 #9aa3ad, 6px 12px 0 #9aa3ad;
}

.dk-filter-row:hover .dk-drag-handle {
    opacity: 1;
}

.dk-filter-row.is-drop-target {
    border-radius: 8px;
    background: #f8fafb;
}

.dk-filter-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.dk-filter-control {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    min-width: 0;
}

.dk-filter-control.is-number {
    grid-template-columns: 150px minmax(0, 1fr);
}

.dk-filter-control.is-number.is-range {
    grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr);
}

.dk-filter-control.is-date-extra {
    grid-template-columns: 180px minmax(0, 1fr);
}

.dk-filter-control.is-date-range,
.dk-filter-control.is-date-month,
.dk-filter-control.is-date-quarter {
    grid-template-columns: 180px minmax(0, 1fr) minmax(0, 1fr);
}

.dk-input,
.dk-select-button,
.dk-token-field {
    min-width: 0;
    min-height: 36px;
    border: 1px solid var(--input-line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-soft);
    font: 15px/1.2 var(--font);
    outline: none;
}

.dk-input {
    width: 100%;
    padding: 0 12px;
}

.dk-input:focus,
.dk-select-button.is-open,
.dk-token-field:focus-within {
    border-color: #0077ff;
}

.dk-select-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    cursor: pointer;
    padding: 0 12px;
    text-align: left;
    white-space: nowrap;
}

.dk-select-button::after {
    content: "";
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-right: 2px solid #6f7c87;
    border-bottom: 2px solid #6f7c87;
    transform: rotate(45deg) translateY(-2px);
}

.dk-token-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
}

.dk-token-field input {
    min-width: 160px;
    flex: 1 1 160px;
    border: 0;
    color: var(--text-soft);
    font: 15px/1.2 var(--font);
    outline: none;
    padding: 4px 0;
}

.dk-token {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-height: 25px;
    border-radius: 6px;
    background: #e6f4ff;
    color: var(--link);
    font-size: 13px;
    line-height: 1;
    padding: 0 8px;
}

.dk-token button,
.dk-remove-field {
    border: 0;
    background: transparent;
    color: #9aa3ad;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.dk-remove-field {
    position: absolute;
    right: 1px;
    top: 28px;
    width: 26px;
    height: 26px;
    font-size: 22px;
    line-height: 22px;
}

.dk-filter-row.has-remove {
    padding-right: 32px;
}

.dk-layer {
    position: fixed;
    z-index: 80;
    min-width: 220px;
    max-width: min(420px, calc(100vw - 24px));
    max-height: 260px;
    overflow: auto;
    border: 1px solid #e5ebf0;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--shadow-menu);
    padding: 8px;
}

.dk-layer[hidden] {
    display: none;
}

.dk-menu-item,
.dk-result-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #686868;
    cursor: pointer;
    font: 15px/1.2 var(--font);
    gap: 8px;
    padding: 0 10px;
    text-align: left;
}

.dk-user-item,
.dk-company-item {
    min-height: 46px;
}

.dk-user-avatar {
    display: inline-grid;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: #dfe6ed;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 600;
}

.dk-item-check {
    margin-left: auto;
    color: var(--link);
    font-size: 16px;
}

.dk-menu-item:hover,
.dk-result-item:hover,
.dk-menu-item.is-active {
    background: #f7f7f7;
    color: var(--control-text-active);
}

.dk-menu-item input {
    width: 15px;
    height: 15px;
    accent-color: var(--link);
}

.dk-result-meta {
    display: block;
    color: #a4afb9;
    font-size: 12px;
    line-height: 1.25;
}

.dk-date-calendar {
    width: 272px;
    max-height: none;
    padding: 14px;
}

.dk-calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.dk-calendar-head button {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #a7adb5;
    cursor: pointer;
    font-size: 22px;
}

.dk-calendar-title {
    color: #30363d;
    font-size: 15px;
    font-weight: 600;
}

.dk-calendar-grid,
.dk-calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.dk-calendar-weekdays {
    margin-bottom: 4px;
    color: #a4afb9;
    font-size: 12px;
}

.dk-calendar-day {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #414b56;
    cursor: pointer;
    font: 14px/30px var(--font);
}

.dk-calendar-day:hover {
    background: #d5f5fe;
}

.dk-calendar-day.is-muted {
    color: #c4ccd4;
}

.dk-calendar-day.is-today {
    color: #00c9fb;
}

.dk-calendar-day.is-selected {
    background: #00c9fb;
    color: #ffffff;
}

.dk-filter-actions {
    position: absolute;
    right: 18px;
    bottom: 18px;
    left: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dk-filter-actions-left,
.dk-filter-actions-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.dk-link-button {
    border: 0;
    background: transparent;
    color: var(--link);
    cursor: pointer;
    font: 14px/1.2 var(--font);
    padding: 0;
}

.dk-link-button.is-muted {
    color: #9aa3ad;
}

.dk-button {
    height: 34px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font: 14px/1.2 var(--font);
    padding: 0 15px;
}

.dk-button-gray {
    background: var(--control-bg);
    color: var(--control-text);
}

.dk-button-gray:hover {
    border-color: var(--control-border);
    background: var(--control-bg-active);
    color: var(--control-text-active);
}

.dk-field-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, .38);
}

.dk-field-modal[hidden] {
    display: none;
}

.dk-field-modal-inner {
    width: min(760px, calc(100vw - 32px));
    max-height: min(760px, calc(100vh - 32px));
    border-radius: 18px;
    background: #ffffff;
    box-shadow: var(--shadow-menu);
    padding: 20px;
}

.dk-field-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.dk-field-modal-head h3 {
    margin: 0;
    color: var(--text);
    font-size: 20px;
    font-weight: 500;
}

.dk-field-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 12px;
    max-height: 380px;
    overflow: auto;
    margin: 14px 0;
}

.dk-field-option {
    display: flex;
    align-items: center;
    min-height: 32px;
    border-radius: 8px;
    color: var(--text-soft);
    gap: 8px;
    padding: 0 8px;
}

.dk-field-option:hover {
    background: #f7f7f7;
}

.dk-field-option input {
    width: 15px;
    height: 15px;
    accent-color: var(--link);
}

.dk-data-table-wrap {
    min-width: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.dk-data-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

.dk-data-table th,
.dk-data-table td {
    border-bottom: 1px solid var(--line);
    color: var(--text-soft);
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
}

.dk-data-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.dk-data-table td {
    font-size: 15px;
    font-weight: 400;
}

.dk-data-table tr:last-child td {
    border-bottom: 0;
}

.dk-empty {
    padding: 18px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 760px) {
    .dk-filter-popover {
        width: 100%;
    }

    .dk-filter-control.is-number,
    .dk-filter-control.is-number.is-range,
    .dk-filter-control.is-date-extra,
    .dk-filter-control.is-date-range,
    .dk-filter-control.is-date-month,
    .dk-filter-control.is-date-quarter {
        grid-template-columns: 1fr;
    }

    .dk-field-list {
        grid-template-columns: 1fr;
    }
}
