:root {
    --sidebar-brand: #ff8a3d;
    --sidebar-brand-soft: rgba(255, 138, 61, 0.15);
    --sidebar-primary: #142140;
    --sidebar-muted: #6b7a93;
    --sidebar-border: rgba(213, 219, 230, 0.8);
    --sidebar-surface: rgba(255, 255, 255, 0.92);
    --sidebar-radius: 18px;
}

@keyframes sidebar-fade-in {
    0% { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes filter-button-pulse {
    0% { box-shadow: 0 14px 32px rgba(255, 138, 61, 0.35); }
    100% { box-shadow: 0 20px 36px rgba(255, 138, 61, 0.45); }
}

.filter-panel {
    position: relative;
    display: block;
    padding: 32px;
    background: linear-gradient(185deg, var(--sidebar-surface), #ffffff 68%);
    border-radius: 26px;
    border: 1px solid var(--sidebar-border);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.16);
    max-width: 360px;
    animation: sidebar-fade-in 0.35s ease both;
    overflow: hidden;
}

.filter-panel::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(246, 247, 251, 0.95));
}

.filter-panel::before {
    content: '';
    position: absolute;
    bottom: 18px;
    left: 50%;
    width: 16px;
    height: 16px;
    border-left: 2px solid rgba(107, 122, 147, 0.55);
    border-bottom: 2px solid rgba(107, 122, 147, 0.55);
    transform: translateX(-50%) rotate(-45deg);
    border-radius: 2px;
    pointer-events: none;
    opacity: 0.65;
}

.filter-panel__form {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.filter-panel__header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-panel__title {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--sidebar-primary);
}

.filter-panel__subtitle {
    margin: 0;
    font-size: 0.93rem;
    line-height: 1.45;
    color: var(--sidebar-muted);
}

.filter-panel__group {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 20px 24px;
    border-radius: var(--sidebar-radius);
    border: 1px solid rgba(209, 214, 226, 0.8);
    background: rgba(248, 250, 252, 0.78);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.filter-panel__group--primary {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(196, 201, 214, 0.65);
}

.filter-panel__group--filters {
    background: rgba(255, 248, 244, 0.84);
    border-color: rgba(255, 138, 61, 0.25);
}

.filter-panel__group-title {
    margin: -6px 0 4px;
    font-size: 0.86rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
    color: #66749a;
}

.filter-panel__group--primary .filter-panel__group-title {
    color: var(--sidebar-brand);
}

.filter-panel__group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: -2px;
    position: sticky;
    top: 18px;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.filter-panel__group-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
    border-radius: 16px;
    z-index: -1;
    pointer-events: none;
}

.filter-panel__collapse {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 138, 61, 0.35);
    background: rgba(255, 255, 255, 0.88);
    color: var(--sidebar-brand);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.filter-panel__collapse:hover {
    border-color: rgba(255, 138, 61, 0.6);
    background: rgba(255, 249, 244, 0.95);
    transform: translateY(-1px);
}

.filter-panel__collapse[aria-expanded="false"] {
    color: var(--sidebar-muted);
}

.filter-active-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #ff9b54, var(--sidebar-brand));
    box-shadow: 0 6px 12px rgba(255, 138, 61, 0.25);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.filter-active-badge[data-count="0"] {
    opacity: 0;
    transform: scale(0.6);
}

.filter-panel__collapse[aria-expanded="true"] .collapse-label::before {
    content: '− ';
}

.filter-panel__collapse[aria-expanded="false"] .collapse-label::before {
    content: '+ ';
}

.collapse-icon {
    width: 12px;
    height: 12px;
    position: relative;
}

.collapse-icon::before,
.collapse-icon::after {
    content: '';
    position: absolute;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s ease;
}

.collapse-icon::before {
    width: 12px;
    height: 2px;
    top: 5px;
    left: 0;
}

.collapse-icon::after {
    width: 2px;
    height: 12px;
    top: 0;
    left: 5px;
}

.filter-panel__collapse[aria-expanded="true"] .collapse-icon::after {
    transform: scaleY(0);
}

.filter-panel__group-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    transition: max-height 0.32s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.24s ease;
    max-height: 1200px;
    opacity: 1;
    overflow: hidden;
}

.filter-panel__group-body.is-collapsed {
    max-height: 0;
    opacity: 0;
}

.filter-panel__section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

fieldset.filter-panel__section + fieldset.filter-panel__section {
    border-top: 1px dashed rgba(209, 214, 226, 0.7);
    padding-top: 14px;
    margin-top: 8px;
}

fieldset.filter-panel__section {
    border: 0;
    padding: 0;
    margin: 0;
}

.filter-panel__section legend {
    margin-bottom: 6px;
}

.filter-panel__section--interactive .filter-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.filter-panel__section--interactive .filter-label::after {
    content: '⌄';
    font-size: 0.88rem;
    color: rgba(91, 104, 131, 0.4);
}

.filter-panel__section--compact {
    align-items: flex-start;
}

.filter-panel__section--compact .filter-input--compact {
    max-width: 240px;
    width: 100%;
}

.filter-legend {
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    color: #7b8bad;
}

.filter-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: #3c4b68;
}

.filter-input,
.filter-select select,
.filter-input__control {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(192, 200, 214, 0.9);
    background-color: #f7f9fc;
    padding: 13px 16px;
    font-size: 0.95rem;
    color: #1b263b;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.filter-input {
    line-height: 1.4;
}

.filter-input::placeholder,
.filter-input__control::placeholder {
    color: rgba(107, 122, 147, 0.7);
}

.filter-input--addon {
    display: flex;
    align-items: center;
    padding: 0;
    border-radius: 18px;
    border: 1px solid rgba(192, 200, 214, 0.9);
    background-color: #f7f9fc;
}

.filter-input__control {
    border: none;
    border-radius: 18px 0 0 18px;
    background-color: transparent;
}

.filter-input__addon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 100%;
    border: none;
    border-radius: 0 18px 18px 0;
    background: transparent;
    color: var(--sidebar-brand);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.filter-input__addon:hover,
.filter-input__addon:focus {
    background-color: var(--sidebar-brand-soft);
    color: var(--sidebar-brand);
    outline: none;
}

.icon-calendar {
    position: relative;
    width: 18px;
    height: 18px;
}

.icon-calendar::before,
.icon-calendar::after {
    content: '';
    position: absolute;
    background: currentColor;
    border-radius: 2px;
}

.icon-calendar::before {
    inset: 3px 0 0;
    border: 2px solid currentColor;
    border-radius: 4px;
}

.icon-calendar::after {
    top: 6px;
    left: 3px;
    right: 3px;
    height: 2px;
}

.filter-input:focus,
.filter-select select:focus,
.filter-input__control:focus {
    outline: none;
    border-color: rgba(255, 138, 61, 0.75);
    box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.18);
    background-color: #ffffff;
}

.filter-input--addon:focus-within {
    border-color: rgba(255, 138, 61, 0.75);
    box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.18);
    background-color: #ffffff;
}

.filter-input--compact {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 220px;
    background: #f7f9fc;
    border-radius: 999px;
    padding: 6px 16px;
    border: 1px solid rgba(192, 200, 214, 0.9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.filter-input--compact .filter-input__control {
    border-radius: 0;
    padding: 0;
}

.filter-input__control--number {
    width: 72px;
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.95rem;
    color: #1b263b;
    text-align: left;
    -moz-appearance: textfield;
}

.filter-input__control--number::-webkit-inner-spin-button,
.filter-input__control--number::-webkit-outer-spin-button {
    margin: 0;
}

.filter-input__control--number:focus {
    outline: none;
}

.filter-input__unit {
    font-size: 0.85rem;
    color: rgba(109, 122, 149, 0.82);
    font-weight: 600;
    letter-spacing: 0.04em;
}

.filter-input--compact:focus-within {
    border-color: rgba(255, 138, 61, 0.75);
    box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.18);
    background-color: #ffffff;
}

.filter-select {
    position: relative;
}

.filter-select::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 18px;
    transform: translateY(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(91, 104, 131, 0.65);
    border-bottom: 2px solid rgba(91, 104, 131, 0.65);
    pointer-events: none;
}

.filter-select select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: transparent;
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 0.95rem;
    color: #3c4b68;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.filter-check:hover {
    background-color: rgba(255, 138, 61, 0.04);
    border-color: rgba(255, 138, 61, 0.14);
    color: #1f2a3f;
    transform: translateY(-0.25px);
}

.filter-check input[type="checkbox"],
.filter-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--sidebar-brand);
    flex-shrink: 0;
}

.filter-check input:focus-visible + span {
    outline: 2px solid rgba(255, 138, 61, 0.4);
    outline-offset: 2px;
    border-radius: 4px;
}

.filter-check input:checked + span {
    color: var(--sidebar-brand);
    font-weight: 600;
}

.filter-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 4px 8px;
    align-items: stretch;
}

.filter-check-grid--single {
    grid-template-columns: 1fr;
}

.filter-check-grid .filter-check {
    height: 100%;
    align-items: flex-start;
}

.filter-check span {
    flex: 1;
    line-height: 1.3;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.filter-panel__divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.35), transparent);
}

.filter-panel__actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 4px;
}

.filter-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 15px 18px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.02rem;
    letter-spacing: 0.02em;
    color: #ffffff;
    background: linear-gradient(132deg, #ff9b54, var(--sidebar-brand));
    box-shadow: 0 14px 32px rgba(255, 138, 61, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.filter-submit:hover {
    transform: translateY(-1px);
    animation: filter-button-pulse 1.2s ease-in-out infinite alternate;
}

.filter-submit:active {
    transform: translateY(0);
    box-shadow: 0 12px 24px rgba(255, 138, 61, 0.4);
}

.filter-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: 16px;
    border: 1px solid rgba(192, 200, 214, 0.65);
    background: rgba(248, 250, 252, 0.95);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--sidebar-muted);
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.filter-reset:hover {
    color: var(--sidebar-brand);
    border-color: rgba(255, 138, 61, 0.4);
    background: rgba(255, 248, 244, 0.98);
}

@media (max-width: 1120px) {
    .filter-panel {
        max-width: 100%;
    }

    .filter-panel__group-header {
        position: static;
        top: auto;
        backdrop-filter: none;
    }

    .filter-panel__group-header::after {
        display: none;
    }
}

@media (max-width: 640px) {
    .filter-panel {
        padding: 28px 24px 32px;
        border-radius: 22px;
    }

    .filter-panel__actions {
        flex-direction: column;
    }

    .filter-check-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .filter-check-grid {
        grid-template-columns: 1fr;
    }
}
