.mvs-agency-half-map-panel {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(150, 134, 99, .28);
    border-radius: 14px;
    background: #f6f5f1;
    box-shadow: 0 14px 34px rgba(30, 68, 53, .14);
}
.mvs-agency-half-map-panel[hidden] { display: none !important; }
.mvs-agency-half-map-panel .map-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: inherit;
    overflow: hidden;
}
.mvs-agency-half-map-head {
    display: flex;
    min-height: 52px;
    padding: 10px 14px 10px 18px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #1e4435;
    color: #fff;
}
.mvs-agency-half-map-head strong { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.mvs-agency-half-map-close {
    display: grid;
    width: 32px;
    height: 32px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
}
.mvs-agency-half-map-close:hover { background: rgba(255,255,255,.14); }
.mvs-agency-half-map-canvas { min-height: 580px; width: 100%; }
.mvs-agency-half-map-empty,
.mvs-agency-map-unavailable {
    position: absolute;
    z-index: 500;
    top: 50%;
    left: 50%;
    width: min(290px, 80%);
    margin: 0;
    padding: 12px 15px;
    transform: translate(-50%, -50%);
    border-radius: 8px;
    background: rgba(255,255,255,.94);
    color: #526159;
    font-size: 12px;
    text-align: center;
    box-shadow: 0 10px 26px rgba(0,0,0,.12);
}
.mvs-agency-directory-pin { background: transparent; border: 0; }
.mvs-agency-directory-pin span {
    display: block;
    width: 26px;
    height: 26px;
    border: 3px solid #fff;
    border-radius: 50% 50% 50% 0;
    background: #968663;
    box-shadow: 0 5px 12px rgba(30,68,53,.3);
    transform: rotate(-45deg);
}
.mvs-agency-directory-pin span::after {
    display: block;
    width: 7px;
    height: 7px;
    margin: 7px auto;
    border-radius: 50%;
    background: #fff;
    content: '';
}
.leaflet-container .leaflet-popup.mvs-agency-leaflet-popup .leaflet-popup-content-wrapper {
    padding: 0 !important;
    overflow: hidden;
    border: 1px solid rgba(150, 134, 99, .30);
    border-radius: 16px !important;
    background: #fff;
    box-shadow: 0 18px 42px rgba(30, 68, 53, .24);
}
.leaflet-popup-pane .leaflet-popup.mvs-agency-leaflet-popup {
    width: min(560px, calc(100vw - 24px)) !important;
}
.leaflet-container .leaflet-popup.mvs-agency-leaflet-popup .leaflet-popup-content {
    width: min(520px, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px);
    margin: 0 !important;
}
.mvs-agency-map-popup {
    width: 100%;
    max-width: none;
    overflow: hidden;
    border-radius: 15px;
    background: #fff;
}
.mvs-agency-map-popup > img {
    display: none !important;
}
.mvs-agency-map-popup-body { padding: 16px 18px 17px; }
.mvs-agency-map-popup strong { display: block; margin-bottom: 8px; color: #1e4435; font-size: 17px; line-height: 1.25; }
.mvs-agency-map-popup-address,
.mvs-agency-map-popup-meta,
.mvs-agency-map-popup-hours {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: 6px;
    color: #68766f;
    font-size: 12px;
    line-height: 1.45;
}
.mvs-agency-map-popup-address .houzez-icon,
.mvs-agency-map-popup-hours .houzez-icon { flex: 0 0 auto; margin-top: 2px; color: #968663; }
.mvs-agency-map-popup-hours em {
    display: block;
    margin-bottom: 1px;
    color: #9a8965;
    font-size: 10px;
    font-style: normal;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.mvs-agency-map-popup-specialties {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 11px;
}
.mvs-agency-map-popup-specialty {
    display: inline-flex;
    padding: 5px 8px;
    border: 1px solid rgba(150, 134, 99, .28);
    border-radius: 999px;
    background: #f6f3eb;
    color: #315345;
    font-size: 10px;
    line-height: 1.2;
}
.mvs-agency-map-popup-link {
    display: inline-flex;
    margin-top: 13px;
    align-items: center;
    gap: 7px;
    color: #968663 !important;
    font-size: 12px;
    font-weight: 700;
}
.mvs-agency-map-popup-link span { font-size: 16px; line-height: 1; transition: transform .2s ease; }
.mvs-agency-map-popup-link:hover span { transform: translateX(3px); }
.leaflet-container .leaflet-popup.mvs-agency-leaflet-popup .leaflet-popup-tip {
    background: #fff;
    box-shadow: 2px 2px 5px rgba(30, 68, 53, .12);
}
.leaflet-container .leaflet-popup.mvs-agency-leaflet-popup .leaflet-popup-close-button {
    z-index: 2;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(30, 68, 53, .76);
    color: #fff;
    font-size: 20px;
    line-height: 26px;
    text-align: center;
}
.leaflet-container .leaflet-popup.mvs-agency-leaflet-popup .leaflet-popup-close-button:hover { background: #968663; color: #fff; }
@media (max-width: 575px) {
    .leaflet-container .leaflet-popup.mvs-agency-leaflet-popup .leaflet-popup-content {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px);
    }
    .mvs-agency-map-popup-body { padding: 14px 15px 15px; }
}
.mvs-agency-map-toggle.is-active { background: #1e4435 !important; border-color: #1e4435 !important; }
.mvs-agency-directory-controls { display: flex; flex: 0 0 auto; flex-direction: column; align-items: stretch; gap: 8px; }
.mvs-agency-directory-controls .mvs-agents-filter-toggle { margin: 0; white-space: nowrap; }
.mvs-agency-directory-wrap.mvs-agency-map-open > .container > .row,
.mvs-agencies-directory-wrap.mvs-agency-map-open > .container > .row { transition: width .25s ease; }
@media (min-width: 992px) {
    /* The native half-map uses a map pane and a scrollable results pane.
       Keep the same widths and breakpoint values as search-result-page, but
       keep the whole block in the document flow so the footer follows it. */
    .mvs-agency-directory-wrap.mvs-agency-map-open,
    .mvs-agencies-directory-wrap.mvs-agency-map-open {
        min-height: var(--mvs-agency-map-height, 100vh);
    }
    /* Keep the document itself scrollable so the footer remains reachable;
       the results column grows naturally beside the sticky map. */
    html.mvs-agency-half-map-open,
    body.mvs-agency-half-map-open { overflow: visible !important; }
    body.mvs-agency-half-map-open { overscroll-behavior: auto; }
    /* Do not let Houzez's native .half-map-wrap height rule stretch the
       directory over the header/search chrome. */
    .mvs-agency-directory-wrap.mvs-agency-map-open,
    .mvs-agencies-directory-wrap.mvs-agency-map-open {
        position: relative !important;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 780px;
        width: 100% !important;
        height: auto !important;
        min-height: var(--mvs-agency-map-height, calc(100vh - 147px));
        align-items: stretch;
    }
    /* Keep the global header and Agency search visible while the document is
       scrolled past the start of the map block. */
    body.mvs-agency-half-map-open .header-main-wrap {
        position: sticky !important;
        top: 0 !important;
        z-index: 1105 !important;
        display: block !important;
        visibility: visible !important;
    }
    body.mvs-agency-half-map-open #agency-search-bar {
        position: sticky !important;
        top: var(--mvs-agency-header-height, 0px) !important;
        z-index: 1104 !important;
        display: block !important;
        visibility: visible !important;
        background: #fff;
    }
    .mvs-agency-half-map-panel.mvs-agency-map-open {
        position: sticky;
        z-index: 1;
        grid-column: 1;
        grid-row: 1;
        align-self: start;
        width: 100%;
        height: var(--mvs-agency-map-height, calc(100vh - 147px));
        min-height: 420px;
        top: calc(var(--mvs-agency-header-height, 0px) + var(--mvs-agency-search-height, 0px));
        float: none;
        border: 0;
        border-radius: 0;
        background: #f4f5f2;
        box-shadow: none;
    }
    .mvs-agency-half-map-panel.mvs-agency-map-open .map-wrap,
    .mvs-agency-half-map-panel.mvs-agency-map-open .mvs-agency-half-map-canvas {
        min-height: 0;
        height: 100%;
    }
    .mvs-agency-half-map-panel.mvs-agency-map-open .mvs-agency-half-map-head { display: none; }
    .mvs-agency-directory-wrap.mvs-agency-map-open > .container,
    .mvs-agencies-directory-wrap.mvs-agency-map-open > .container {
        position: relative;
        z-index: 2;
        grid-column: 2;
        grid-row: 1;
        width: 100%;
        max-width: none;
        float: none;
        height: auto;
        margin: 0;
        padding: 25px 25px 45px;
        overflow-x: hidden;
        overflow-y: visible;
        border-left: 1px solid #e2e6e2;
        background: #fff;
        box-sizing: border-box;
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open .mvs-pro-directory-intro,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .mvs-pro-directory-intro { display: none; }
    .mvs-agency-directory-wrap.mvs-agency-map-open .mvs-agents-filter-bar,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .mvs-agents-filter-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-top: 0;
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open .mvs-pro-join-card,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .mvs-pro-join-card {
        grid-template-columns: 1fr;
        width: 100%;
        box-sizing: border-box;
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open .mvs-pro-join-link,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .mvs-pro-join-link {
        justify-self: end;
        width: auto !important;
        max-width: 100%;
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open .mvs-agency-directory-controls,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .mvs-agency-directory-controls {
        width: auto;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 9px;
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open .mvs-agency-directory-controls .mvs-agents-filter-toggle,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .mvs-agency-directory-controls .mvs-agents-filter-toggle {
        width: auto !important;
        flex: 0 0 auto;
        min-width: 112px;
        justify-content: center;
    }
    /* Keep the map toggle visible while the results column is inspected. */
    .mvs-agency-directory-wrap.mvs-agency-map-open .mvs-agency-map-toggle,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .mvs-agency-map-toggle {
        position: sticky;
        z-index: 1003;
        top: 12px;
        width: auto !important;
        min-width: 112px;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(30,68,53,.18);
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open > .container > .row,
    .mvs-agencies-directory-wrap.mvs-agency-map-open > .container > .row { margin-right: 0; margin-left: 0; }
    .mvs-agency-directory-wrap.mvs-agency-map-open > .container > .row > [class*="col-"],
    .mvs-agencies-directory-wrap.mvs-agency-map-open > .container > .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        margin-left: 0;
        padding-right: 0;
        padding-left: 0;
        box-sizing: border-box;
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open .mvs-agency-sidebar-column,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .mvs-agency-sidebar-column { display: none; }
    .mvs-agency-directory-wrap.mvs-agency-map-open .right-bt-content,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .right-bt-content { width: 100%; max-width: 100%; flex: 0 0 100%; }
    .mvs-agency-directory-wrap.mvs-agency-map-open .agents-list-view,
    .mvs-agency-directory-wrap.mvs-agency-map-open .agencies-grid-view,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .agents-list-view,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .agencies-grid-view {
        width: 100%;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open .agencies-grid-view,
    .mvs-agencies-directory-wrap.mvs-agency-map-open .agencies-grid-view { grid-template-columns: 1fr !important; }
}
@media (min-width: 992px) and (max-width: 1200px) {
    .mvs-agency-directory-wrap.mvs-agency-map-open,
    .mvs-agencies-directory-wrap.mvs-agency-map-open { grid-template-columns: minmax(0, 1fr) 640px; }
    .mvs-agency-half-map-panel.mvs-agency-map-open { width: 100%; }
    .mvs-agency-directory-wrap.mvs-agency-map-open > .container,
    .mvs-agencies-directory-wrap.mvs-agency-map-open > .container { width: 100%; }
}
@media (max-width: 991px) {
    /* Mobile must also stay in normal flow: the legacy .half-map-wrap rule
       otherwise gives the section a 100% height and leaves the footer below
       an unreachable scroll context. */
    .mvs-agency-directory-wrap.mvs-agency-map-open,
    .mvs-agencies-directory-wrap.mvs-agency-map-open {
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
    .mvs-agency-half-map-panel.mvs-agency-map-open {
        width: 100% !important;
        height: clamp(360px, 68vh, 560px) !important;
        min-height: 360px;
        margin: 0 0 22px;
    }
    .mvs-agency-directory-wrap.mvs-agency-map-open > .container,
    .mvs-agencies-directory-wrap.mvs-agency-map-open > .container {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding-bottom: 30px;
    }
    .mvs-agency-directory-controls { width: 100%; }
}

/* The directory map is an in-flow section.  Explicitly release any legacy
   half-map overflow/height rule so the site footer remains a real document
   sibling below the map and result content. */
body.mvs-agency-half-map-open .mvs-agency-directory-wrap,
body.mvs-agency-half-map-open .mvs-agencies-directory-wrap {
    overflow: visible !important;
    clear: both !important;
}
body.mvs-agency-half-map-open #main-wrap {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
}
body.mvs-agency-half-map-open footer.footer-wrap,
body.post-type-archive-houzez_agency footer.footer-wrap,
body.page-template-template-agencies footer.footer-wrap {
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 0 !important;
    clear: both !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
}
