/* Universal Main Filter Modal — layout + responsive */

.mf-backdrop {
    z-index: 4100;
}

.mf-modal {
    width: min(920px, 100%);
    max-height: min(92vh, 900px);
    display: flex;
    flex-direction: column;
}

.mf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mf-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mf-tabs {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border, #e0e0e0);
    background: #f8fafc;
    flex-shrink: 0;
}

.mf-tab {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-light, #666);
    padding: 12px 14px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    min-height: 44px;
}

.mf-tab.active {
    color: var(--primary, #1e88e5);
    border-bottom-color: var(--primary, #1e88e5);
}

.mf-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.mf-tab-content {
    display: none;
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

.mf-tab-content.active {
    display: flex;
}

.mf-scroll-area {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px 4px 8px;
    max-height: min(58vh, 560px);
}

.mf-section {
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 10px;
    background: #fff;
    margin-bottom: 12px;
    overflow: hidden;
}

.mf-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: #f5f8fb;
    font-weight: 700;
    color: var(--primary-dark, #1565c0);
}

.mf-section-header.mf-collapsible {
    cursor: pointer;
    user-select: none;
    min-height: 44px;
}

.mf-section-body {
    padding: 12px 14px 14px;
}

.mf-section.is-collapsed .mf-section-body {
    display: none;
}

.mf-section.is-collapsed .mf-collapse-icon {
    transform: rotate(180deg);
}

.mf-collapse-icon {
    transition: transform .2s ease;
}

.mf-form-row {
    display: grid;
    grid-template-columns: minmax(88px, 140px) minmax(0, 1fr);
    gap: 8px 12px;
    align-items: center;
    margin-bottom: 10px;
}

.mf-form-row:last-child {
    margin-bottom: 0;
}

.mf-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light, #666);
}

.mf-input,
.mf-select {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
    background: #fff;
    font: inherit;
}

.mf-input:focus,
.mf-select:focus {
    outline: none;
    border-color: var(--primary, #1e88e5);
    box-shadow: 0 0 0 3px rgba(30, 136, 229, .15);
}

.mf-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
}

.mf-mt8 {
    margin-top: 8px;
}

.mf-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mf-code-sm {
    flex: 0 0 88px;
    max-width: 110px;
}

.mf-flex1 {
    flex: 1 1 auto;
    min-width: 0;
}

.mf-picker-btn {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    color: var(--primary, #1e88e5);
}

.mf-picker-btn:hover {
    background: var(--primary-light, #e3f2fd);
}

.mf-radio-group,
.mf-check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.mf-hidden {
    display: none !important;
}

.mf-no-section {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-light, #666);
}

.mf-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.mf-goods-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    flex: 1;
    padding-top: 4px;
}

.mf-goods-search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.mf-goods-search-bar > .mf-input {
    flex: 1 1 220px;
}

.mf-goods-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(180px, .8fr);
    gap: 12px;
    min-height: 0;
}

.mf-goods-table-wrap {
    height: min(42vh, 420px);
    min-height: min(42vh, 420px);
    max-height: min(42vh, 420px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
}

.mf-goods-selected-panel {
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    min-height: 180px;
    max-height: min(42vh, 420px);
}

.mf-goods-selected-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    font-weight: 700;
    border-bottom: 1px solid var(--border, #e0e0e0);
}

.mf-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--primary, #1e88e5);
    color: #fff;
    font-size: 12px;
}

.mf-goods-selected-list {
    list-style: none;
    margin: 0;
    padding: 8px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

.mf-goods-selected-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px 12px;
    border-top: 1px solid var(--border, #e0e0e0);
}

.mf-action-link {
    appearance: none;
    border: none;
    background: none;
    color: var(--primary, #1e88e5);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    min-height: 36px;
}

.mf-action-link.danger {
    color: var(--danger, #f44336);
}

.mf-table-empty {
    text-align: center;
    color: var(--text-light, #666);
    padding: 24px 12px !important;
}

@media (max-width: 900px) {
    .mf-modal {
        width: min(100%, 100vw);
    }

    .mf-goods-layout {
        grid-template-columns: 1fr;
    }

    .mf-goods-selected-panel {
        max-height: 220px;
    }
}

@media (max-width: 768px) {
    .mf-modal {
        max-height: 96vh;
        border-radius: 12px 12px 0 0;
        align-self: flex-end;
    }

    .mf-scroll-area {
        max-height: calc(96vh - 210px);
    }

    .mf-grid-2 {
        grid-template-columns: 1fr;
    }

    .mf-form-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .mf-label {
        text-align: right;
    }

    .mf-picker-wrap {
        flex-wrap: wrap;
    }

    .mf-code-sm {
        flex: 1 1 90px;
        max-width: none;
    }

    .mf-footer {
        flex-direction: column-reverse;
    }

    .mf-footer .modal-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .mf-input,
    .mf-select {
        font-size: 16px;
        min-height: 44px;
    }

    .mf-goods-search-bar .mf-form-row {
        width: 100%;
        min-width: 0 !important;
    }
}

@media (max-width: 480px) {
    .mf-tabs {
        padding: 0 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mf-tab {
        white-space: nowrap;
        padding: 10px 12px;
    }

    .mf-section-body {
        padding: 10px;
    }
}
