:root {
    --map-available: #16805d;
    --map-reserved: #d79a00;
    --map-sold: #bd3b35;
    --map-blocked: #667078;
    --map-padrao-1: #0e9a6b; /* verde esmeralda — Padrão 1 */
    --map-padrao-1-stroke: #0c4a33;
    --map-padrao-2: #ff8c2e; /* laranja vivo — Padrão 2 */
    --map-padrao-2-stroke: #7a3d00;
    --map-padrao-3: #3867ff; /* azul royal — Padrão 3 */
    --map-padrao-3-stroke: #1e2f8a;
    --map-surface: #fffdf8;
    --map-ink: #173d38;
    --map-muted: #5e6d69;
    --map-line: #d8ded9;
}

.map-page { overflow: hidden; }
.map-page .site-footer { display: none; }
.map-page #conteudo { min-height: calc(100dvh - 5.25rem); }

.map-explorer {
    display: grid;
    grid-template-columns: minmax(20rem, 25rem) minmax(0, 1fr);
    height: calc(100dvh - 5.25rem);
    min-height: 35rem;
    background: #d8e1dc;
}

.map-sidebar {
    position: relative;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
    min-width: 0;
    overflow-y: auto;
    padding: 2rem;
    color: var(--map-ink);
    background: var(--map-surface);
    border-right: 1px solid var(--map-line);
    box-shadow: 12px 0 32px rgba(23, 61, 56, .09);
}

.map-sidebar-head .eyebrow { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.map-sidebar-head h1 { margin-bottom: .65rem; font-size: clamp(2rem, 3vw, 3.15rem); line-height: .98; }
.map-sidebar-head > p:last-child,
.map-help p { margin: 0; color: var(--map-muted); line-height: 1.55; }

.map-filters label { display: block; margin-bottom: .45rem; font-weight: 700; }
.map-filters select {
    width: 100%;
    min-height: 3rem;
    padding: .65rem 2.5rem .65rem .8rem;
    color: var(--map-ink);
    background-color: #fff;
    border: 1px solid #9ca9a4;
    border-radius: .25rem;
}
.map-filters select:disabled { cursor: not-allowed; opacity: .6; }

.map-summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding-block: .9rem;
    border-block: 1px solid var(--map-line);
}
.map-summary strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.map-summary > span { color: var(--map-muted); font-size: .8rem; text-align: right; }

.map-status-grid { display: grid; gap: .25rem; }
.map-status-grid > div {
    display: grid;
    grid-template-columns: 1rem 1fr auto;
    align-items: center;
    gap: .65rem;
    min-height: 2.5rem;
    padding: .35rem .5rem;
}
.map-status-grid > div:nth-child(even) { background: #f4f3ee; }
.map-status-grid strong { font-variant-numeric: tabular-nums; }

.status-swatch {
    display: inline-block;
    width: .8rem;
    height: .8rem;
    flex: 0 0 .8rem;
    border: 2px solid rgba(0, 0, 0, .26);
    border-radius: 2px;
}
.status-swatch.status-available { background: var(--map-available) !important; }
.status-swatch.status-reserved { background: var(--map-reserved) !important; border-style: dashed; }
.status-swatch.status-sold { background: var(--map-sold) !important; }
.status-swatch.status-blocked { background: var(--map-blocked) !important; background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(255,255,255,.45) 3px 5px) !important; }

.status-swatch.padron-1 { background: var(--map-padrao-1) !important; border-color: var(--map-padrao-1-stroke) !important; }
.status-swatch.padron-2 { background: var(--map-padrao-2) !important; border-color: var(--map-padrao-2-stroke) !important; border-style: dashed !important; }
.status-swatch.padron-3 { background: var(--map-padrao-3) !important; border-color: var(--map-padrao-3-stroke) !important; background-image: radial-gradient(circle, rgba(255,255,255,.35) 1.5px, transparent 1.5px) !important; background-size: 6px 6px !important; }
/* Fallback para padroes não mapeados */
.status-swatch[class*="padron-"] { border: 2px solid rgba(0,0,0,.26); }

/* Labels de padrão no mapa */
.padrao-label {
    background: transparent !important;
    border: none !important;
}
.padrao-label span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.9rem;
    height: 1.9rem;
    padding: 0 .4rem;
    color: #fff;
    font-family: "Josefin Sans", sans-serif;
    font-size: .78rem;
    font-weight: 800;
    line-height: 1;
    border-radius: 999rem;
    border: 2px solid rgba(255,255,255,.95);
    box-shadow: 0 2px 8px rgba(0,0,0,.28);
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.padrao-label.padron-1 span { background: var(--map-padrao-1); }
.padrao-label.padron-2 span { background: var(--map-padrao-2); color: #1a1a1a; border-color: rgba(255,255,255,.95); text-shadow: none; }
.padrao-label.padron-3 span { background: var(--map-padrao-3); }

/* Filtros de padrão */
.map-padrao-grid { display: grid; gap: .35rem; margin-top: .4rem; }
.map-padrao-grid > label {
    display: grid;
    grid-template-columns: 1rem 1fr auto;
    align-items: center;
    gap: .65rem;
    min-height: 2.6rem;
    padding: .35rem .6rem;
    background: #fff;
    border: 1px solid var(--map-line);
    border-radius: .25rem;
    cursor: pointer;
    transition: background .15s, border-color .15s, opacity .15s;
}
.map-padrao-grid > label:hover { background: #f4f3ee; }
.map-padrao-grid > label.is-off { opacity: .45; background: #f4f3ee; border-style: dashed; }
.map-padrao-grid input { width:1.05rem; height:1.05rem; accent-color: var(--map-ink); }
.map-padrao-grid strong { font-variant-numeric: tabular-nums; }

/* Legenda melhorada */
.map-legend { flex-direction: column; gap: .6rem; min-width: 16rem; }
.map-legend-title { font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--map-muted); }
.map-legend-section { display: flex; flex-wrap: wrap; gap: .6rem 1rem; }
.map-legend-padros { display: flex; flex-wrap: wrap; gap: .5rem .9rem; }
.map-legend-padros button {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .25rem .5rem;
    background: #fff;
    border: 1px solid var(--map-line);
    border-radius: 999rem;
    font: inherit; font-size: .76rem; font-weight: 700;
    cursor: pointer;
}
.map-legend-padros button.is-off { opacity:.45; text-decoration: line-through; }
.map-legend-padros button:hover { border-color: var(--map-ink); }

.map-help {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .75rem;
    margin-top: auto;
    padding: 1rem;
    background: #f1eee5;
    border-left: 3px solid var(--map-ink);
}
.map-help .bi { margin-top: .2rem; font-size: 1.15rem; }

.map-stage { position: relative; min-width: 0; min-height: 0; }
.leaflet-map { width: 100%; height: 100%; min-height: 32rem; background: #d8e1dc; }
.leaflet-container { font-family: "Josefin Sans", sans-serif; }
.leaflet-control-attribution { font-size: .68rem; }
.leaflet-bar a { color: var(--map-ink); }
.leaflet-interactive:focus { outline: 3px solid #fff; outline-offset: 2px; }

.leaflet-control-layers {
    color: var(--map-ink);
    background: rgba(255, 253, 248, .96);
    border: 1px solid var(--map-line);
    border-radius: .25rem;
    box-shadow: 0 5px 20px rgba(23, 61, 56, .12);
    font-size: .82rem;
    font-weight: 700;
}
.leaflet-control-layers-list { margin: .2rem; }
.leaflet-control-layers-base label {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-height: 2.75rem;
    padding: .35rem .65rem;
    cursor: pointer;
}
.leaflet-control-layers-base label:hover { background: #f1eee5; }
.leaflet-control-layers-base input { accent-color: var(--map-ink); }

.map-loading,
.map-feedback,
.map-empty {
    position: absolute;
    z-index: 500;
    left: 50%;
    top: 50%;
    display: flex;
    align-items: center;
    gap: .7rem;
    transform: translate(-50%, -50%);
    padding: 1rem 1.25rem;
    color: var(--map-ink);
    background: rgba(255, 253, 248, .96);
    border: 1px solid var(--map-line);
    box-shadow: 0 12px 35px rgba(23, 61, 56, .18);
}
.map-feedback,
.map-empty { flex-direction: column; width: min(22rem, calc(100% - 2rem)); text-align: center; }
.map-feedback .bi,
.map-empty .bi { font-size: 1.6rem; }
.map-spinner {
    width: 1.2rem;
    height: 1.2rem;
    border: 2px solid #a9b7b2;
    border-top-color: var(--map-ink);
    border-radius: 50%;
    animation: map-spin .7s linear infinite;
}
@keyframes map-spin { to { transform: rotate(360deg); } }

.map-legend {
    position: absolute;
    z-index: 450;
    right: 1rem;
    bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: .7rem 1rem;
    max-width: calc(100% - 2rem);
    padding: .75rem 1rem;
    color: var(--map-ink);
    background: rgba(255, 253, 248, .95);
    border: 1px solid var(--map-line);
    box-shadow: 0 5px 20px rgba(23, 61, 56, .12);
    font-size: .78rem;
}
.map-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.map-legend .status-swatch { width: .8rem; height: .8rem; border-radius: 2px; }

.parcel-popup { min-width: 14.5rem; color: var(--map-ink); }
.parcel-popup__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.parcel-popup__head strong { font-family: "Cinzel", serif; font-size: 1.05rem; }
.parcel-popup__status { display: inline-flex; align-items: center; gap: .35rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.parcel-popup dl { display: grid; grid-template-columns: 1fr auto; gap: .4rem 1rem; margin: 0; }
.parcel-popup dt { color: var(--map-muted); font-weight: 500; }
.parcel-popup dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.parcel-popup__message { margin: .5rem 0 0; line-height: 1.45; }
.parcel-popup__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1rem; }
.parcel-popup__actions a { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: .55rem .7rem; font-size: .78rem; font-weight: 700; text-decoration: none; }
.parcel-popup__details { color: var(--map-ink); border: 1px solid var(--map-ink); }
.parcel-popup__reserve { color: #fff !important; background: var(--map-ink); border: 1px solid var(--map-ink); }
.parcel-popup__distance { margin: .85rem 0 .65rem; padding: .65rem .75rem; color: var(--map-muted); background: #f1eee5; font-size: .78rem; line-height: 1.45; }
.parcel-popup__navigate { width: 100%; min-height: 2.75rem; padding: .55rem .7rem; color: #fff; background: var(--map-ink); border: 1px solid var(--map-ink); cursor: pointer; font: inherit; font-size: .78rem; font-weight: 700; }
.parcel-popup__navigate:hover { background: #245950; }
.parcel-popup__map-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .6rem; }
.parcel-popup__map-actions button { min-height: 2.75rem; padding: .55rem .6rem; border: 1px solid var(--map-ink); cursor: pointer; font: inherit; font-size: .76rem; font-weight: 700; }
.parcel-popup__locate { color: var(--map-ink); background: #fff; }
.parcel-popup__tour { color: #fff; background: var(--map-ink); }
.parcel-popup__map-actions button:hover,
.parcel-popup__map-actions button:focus-visible { outline: 2px solid var(--map-ink); outline-offset: 2px; }

.tour-dialog {
    width: min(72rem, calc(100vw - 2rem));
    max-width: none;
    height: min(48rem, calc(100dvh - 2rem));
    max-height: none;
    padding: 0;
    color: var(--map-ink);
    background: transparent;
    border: 0;
}
.tour-dialog::backdrop { background: rgba(8, 28, 26, .76); backdrop-filter: blur(5px); }
.tour-dialog__surface { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: 100%; overflow: hidden; background: var(--map-surface); border: 1px solid rgba(255,255,255,.32); box-shadow: 0 28px 80px rgba(0,0,0,.38); }
.tour-dialog__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; padding: 1.25rem 1.4rem; border-bottom: 1px solid var(--map-line); }
.tour-dialog__header .eyebrow { margin: 0 0 .3rem; }
.tour-dialog__header h2 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.2rem); }
.tour-dialog__header p:last-child { max-width: 42rem; margin: .35rem 0 0; color: var(--map-muted); font-size: .86rem; }
.tour-dialog__close { display: grid; width: 2.75rem; height: 2.75rem; flex: 0 0 2.75rem; place-items: center; color: var(--map-ink); background: #f1eee5; border: 1px solid var(--map-line); cursor: pointer; font-size: 1.1rem; }
.tour-dialog__close:hover,
.tour-dialog__close:focus-visible { color: #fff; background: var(--map-ink); outline: 3px solid rgba(22,128,93,.28); outline-offset: 2px; }
.tour-dialog__body { position: relative; min-height: 18rem; background: #d8e1dc; }
.tour-dialog__panorama { width: 100%; height: 100%; min-height: 18rem; }
.tour-dialog__status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .65rem; padding: 2rem; text-align: center; background: #edf1ed; }
.tour-dialog__status strong { font-family: "Cinzel", serif; font-size: clamp(1.1rem, 2vw, 1.45rem); }
.tour-dialog__status > span:last-child { max-width: 32rem; color: var(--map-muted); line-height: 1.5; }
.tour-dialog__fallback { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 18rem; background: #edf1ed; }
.tour-dialog__fallback[hidden] { display: none !important; }
.tour-fallback__map { width: 100%; height: 18rem; min-height: 18rem; background: #d8e1dc; border-bottom: 1px solid var(--map-line); }
.tour-fallback__content { display: flex; flex-direction: column; gap: .85rem; padding: 1.2rem 1.4rem; }
.tour-fallback__coords { margin: 0; color: var(--map-ink); font-size: .88rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tour-fallback__actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.tour-fallback__actions .button { min-height: 2.75rem; padding: .6rem 1rem; font-size: .82rem; text-decoration: none; }
.tour-fallback__note { margin: 0; color: var(--map-muted); font-size: .78rem; line-height: 1.5; }
.tour-dialog__footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.4rem; border-top: 1px solid var(--map-line); }
.tour-dialog__footer span { font-weight: 700; }
.tour-dialog__footer small { color: var(--map-muted); text-align: right; }

.geolocation-control {
    display: grid;
    gap: .35rem;
    min-width: min(15rem, calc(100vw - 2rem));
    padding: .45rem;
    color: var(--map-ink);
    background: rgba(255, 253, 248, .96);
    border: 1px solid var(--map-line);
    border-radius: .25rem;
    box-shadow: 0 5px 20px rgba(23, 61, 56, .12);
}
.map-location-button { min-height: 2.75rem; padding: .55rem .75rem; color: #fff; background: var(--map-ink); border: 1px solid var(--map-ink); cursor: pointer; font: inherit; font-weight: 700; text-align: left; }
.map-location-button:hover, .map-location-button:focus-visible, .map-location-button.is-active { background: #245950; }
.map-follow-control { display: flex; align-items: center; gap: .35rem; min-height: 2.5rem; padding: .25rem .35rem; cursor: pointer; font-size: .78rem; font-weight: 700; }
.map-follow-control input { width: 1.1rem; height: 1.1rem; accent-color: var(--map-ink); }
.map-location-status { max-width: 24rem; margin: 0; padding: 0 .35rem .25rem; color: var(--map-muted); font-size: .7rem; line-height: 1.4; }
.user-location-icon { background: transparent; border: 0; }
.user-location-dot { position: relative; display: grid; width: 2rem; height: 2rem; place-items: center; color: #fff; background: #1463c3; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 2px 10px rgba(20, 99, 195, .35); }
.user-location-heading { position: absolute; top: -.8rem; left: 50%; color: #1463c3; font-size: 1.45rem; font-weight: 900; line-height: 1; text-shadow: 0 0 2px #fff; transform-origin: 50% 1.8rem; }

@media (max-width: 767.98px) {
    .map-page { overflow: auto; }
    .map-page #conteudo { min-height: 0; }
    .map-explorer { grid-template-columns: 1fr; height: auto; min-height: calc(100dvh - 4.6rem); }
    .map-sidebar { gap: 1rem; overflow: visible; padding: 1.25rem 1rem; border-right: 0; border-bottom: 1px solid var(--map-line); }
    .map-sidebar-head h1 { font-size: 2rem; }
    .map-status-grid { grid-template-columns: 1fr 1fr; }
    .map-help { display: none; }
    .map-stage { height: max(31rem, 62dvh); }
    .map-legend { left: .75rem; right: .75rem; bottom: .75rem; justify-content: center; }
    .geolocation-control { margin-top: .75rem; margin-left: .75rem; }
    .tour-dialog { width: 100vw; height: 100dvh; }
    .tour-dialog__header { padding: 1rem; }
    .tour-dialog__header p:last-child { display: none; }
    .tour-dialog__footer { align-items: flex-start; flex-direction: column; padding: .75rem 1rem; }
    .tour-dialog__footer small { text-align: left; }
}

@media (max-width: 390px) {
    .map-status-grid { grid-template-columns: 1fr; }
    .map-legend { gap: .45rem .75rem; font-size: .72rem; }
}

@media (max-width: 767.98px) {
    .leaflet-control-layers {
        margin-top: .75rem;
        margin-right: .75rem;
    }
    .leaflet-control-layers-base label { min-height: 2.9rem; }
}

@media (max-height: 560px) and (orientation: landscape) {
    .map-explorer { grid-template-columns: 18rem 1fr; height: calc(100dvh - 4.6rem); min-height: 24rem; }
    .map-sidebar { padding: 1rem; }
    .map-sidebar-head h1 { font-size: 1.65rem; }
    .map-help { display: none; }
    .leaflet-map { min-height: 24rem; }
}

@media (prefers-reduced-motion: reduce) {
    .map-spinner { animation: none; border-top-color: #a9b7b2; }
    .tour-dialog::backdrop { backdrop-filter: none; }
}
