/* Leaflet core fallback: ensures tiles are positioned correctly if CDN CSS does not load */
.leaflet-container {
    overflow: hidden;
    background: #dfe7ee;
    outline-offset: 1px;
    direction: ltr;
    -webkit-tap-highlight-color: transparent;
}
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer { position: absolute; left: 0; top: 0; }
.leaflet-container { font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; }
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow { user-select: none; -webkit-user-drag: none; }
.leaflet-tile { filter: inherit; visibility: hidden; }
.leaflet-tile-loaded { visibility: inherit; }
.leaflet-zoom-animated { transform-origin: 0 0; }
.leaflet-zoom-anim .leaflet-zoom-animated { transition: transform .25s cubic-bezier(0,0,.25,1); }
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile { transition: none; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; float: left; clear: both; }
.leaflet-top,
.leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; }
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-control-zoom a {
    display: block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    text-decoration: none;
    background: #fff;
}
.leaflet-control-zoom-in { font: bold 18px Arial, Helvetica, sans-serif; }
.leaflet-control-zoom-out { font: bold 22px Arial, Helvetica, sans-serif; }
.leaflet-disabled { cursor: default; opacity: .55; }
.leaflet-popup { position: absolute; text-align: center; margin-bottom: 20px; }
.leaflet-popup-content-wrapper { padding: 1px; text-align: left; border-radius: 12px; }
.leaflet-popup-content { line-height: 1.4; }
.leaflet-popup-tip-container { width: 40px; height: 20px; position: absolute; left: 50%; margin-left: -20px; overflow: hidden; pointer-events: none; }
.leaflet-popup-tip { width: 17px; height: 17px; padding: 1px; margin: -10px auto 0; transform: rotate(45deg); background: #fff; }
.leaflet-popup-close-button { position: absolute; top: 0; right: 0; border: none; text-align: center; width: 24px; height: 24px; font: 16px/24px Tahoma, Verdana, sans-serif; color: #757575; text-decoration: none; background: transparent; z-index: 2; }
.leaflet-tooltip { position: absolute; padding: 6px; background-color: #fff; border: 1px solid #fff; border-radius: 3px; color: #222; white-space: nowrap; user-select: none; pointer-events: none; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.leaflet-interactive { cursor: pointer; }
.leaflet-grab { cursor: grab; }
.leaflet-dragging .leaflet-grab { cursor: grabbing; }

:root {
    --pm-primary: #0f4c81;
    --pm-primary-dark: #092e4f;
    --pm-gold: #f0b429;
    --pm-text: #142033;
    --pm-muted: #607086;
    --pm-card: #ffffff;
    --pm-soft: #f7fafc;
    --pm-border: rgba(15, 76, 129, .14);
    --pm-shadow: 0 16px 50px rgba(15, 32, 55, .18);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    font-family: Tahoma, Arial, sans-serif;
    color: var(--pm-text);
    overflow: hidden;
    background: #eef3f8;
}

.pm-app,
.pm-map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

.pm-map { z-index: 1; direction: ltr; }
.pm-map .leaflet-popup-content,
.pm-map .pm-parcel-popup-card { direction: rtl; }

.pm-topbar {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    left: 14px;
    right: 14px;
    z-index: 800;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}

.pm-brand,
.pm-stats,
.pm-notice,
.pm-tools {
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(255,255,255,.75);
    box-shadow: var(--pm-shadow);
    backdrop-filter: blur(14px);
}

.pm-brand {
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 18px;
    padding: 10px 12px;
    pointer-events: auto;
}

.pm-brand-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-dark));
    color: #fff;
    font-weight: 900;
    border: 0;
    cursor: pointer;
}

.pm-brand strong {
    display: block;
    font-size: 16px;
    line-height: 1.35;
}
.pm-brand small {
    display: block;
    margin-top: 2px;
    color: var(--pm-muted);
    font-size: 12px;
    line-height: 1.45;
}

.pm-side-boxes {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    pointer-events: auto;
}

.pm-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 999px;
    padding: 10px 13px;
    font-size: 13px;
    white-space: nowrap;
}
.pm-stats b { color: var(--pm-primary); }

.pm-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 16px;
}

.pm-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    border: 0;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-dark));
    color: #fff;
    text-decoration: none;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    white-space: nowrap;
}

.pm-tool-btn-secondary {
    background: #eef5fb;
    color: var(--pm-primary-dark);
}

.pm-notice {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    right: 18px;
    left: 18px;
    z-index: 850;
    max-width: 680px;
    margin: 0 auto;
    border-radius: 18px;
    padding: 12px 14px;
    text-align: center;
    color: var(--pm-text);
    font-size: 13px;
}

.leaflet-control-zoom {
    border: 0 !important;
    box-shadow: var(--pm-shadow) !important;
    overflow: hidden;
    border-radius: 14px !important;
}
.leaflet-control-zoom a {
    border: 0 !important;
    color: var(--pm-primary-dark) !important;
    font-weight: 900;
}
.leaflet-popup-content-wrapper {
    border-radius: 20px;
    box-shadow: 0 22px 60px rgba(15,32,55,.24);
}
.leaflet-popup-content { margin: 0; min-width: 260px; }
.leaflet-popup-tip { box-shadow: none; }

.pm-parcel-popup-card {
    min-width: 260px;
    max-width: 315px;
    direction: rtl;
    text-align: right;
    overflow: hidden;
    border-radius: 20px;
    font-family: Tahoma, Arial, sans-serif;
}

.pm-popup-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding: 15px 16px 13px;
    background: linear-gradient(135deg, #fffaf0, #ffffff);
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.pm-popup-title {
    margin: 0;
    font-size: 17px;
    line-height: 1.45;
    font-weight: 900;
    color: var(--pm-primary-dark);
}
.pm-popup-subtitle {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--pm-muted);
}
.pm-popup-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(240,180,41,.16);
    color: #8a6513;
    font-size: 11px;
    font-weight: 900;
    white-space: nowrap;
}
.pm-popup-rows {
    display: grid;
    gap: 8px;
    padding: 13px 14px;
    background: #fff;
}
.pm-popup-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    background: var(--pm-soft);
    border: 1px solid rgba(15,76,129,.06);
    border-radius: 12px;
    padding: 9px 10px;
}
.pm-popup-label {
    color: var(--pm-muted);
    font-size: 12px;
    font-weight: 700;
}
.pm-popup-value {
    color: var(--pm-text);
    font-size: 13px;
    font-weight: 900;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pm-popup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 14px 14px;
    background: #fff;
}
.pm-share-btn,
.pm-copy-btn {
    width: 100%;
    border: 0;
    border-radius: 13px;
    padding: 11px 10px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.pm-share-btn {
    color: #fff;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-dark));
    box-shadow: 0 8px 20px rgba(15,76,129,.22);
}
.pm-copy-btn {
    color: var(--pm-primary-dark);
    background: #eef5fb;
}
.pm-share-btn:hover,
.pm-copy-btn:hover,
.pm-tool-btn:hover { transform: translateY(-1px); }
.pm-share-btn:active,
.pm-copy-btn:active,
.pm-tool-btn:active { transform: translateY(0); opacity: .88; }

.pm-parcel-tooltip {
    background: rgba(255,255,255,.97);
    border: 1px solid rgba(15, 76, 129, .25);
    border-radius: 999px;
    color: #12212f;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    padding: 5px 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,.12);
    white-space: nowrap;
}
.pm-parcel-tooltip:before { display: none; }

.pm-plan-title-icon,
.pm-parcel-number-icon {
    background: transparent;
    border: 0;
}

.pm-plan-title-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,.97);
    border: 1px solid rgba(15,76,129,.15);
    box-shadow: 0 8px 24px rgba(0,0,0,.14);
    color: var(--pm-primary-dark);
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
    pointer-events: none;
}

.pm-parcel-number-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.98);
    border: 1px solid rgba(15,76,129,.22);
    box-shadow: 0 6px 18px rgba(0,0,0,.14);
    color: #1a1a1a;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
    pointer-events: none;
}

@media (max-width: 860px) {
    .pm-topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }
    .pm-brand {
        min-width: 0;
        width: 100%;
        border-radius: 16px;
        padding: 9px 10px;
    }
    .pm-brand-icon { width: 36px; height: 36px; border-radius: 10px; }
    .pm-side-boxes {
        width: 100%;
        align-items: flex-start;
    }
    .pm-stats {
        width: fit-content;
        padding: 8px 11px;
        font-size: 11px;
    }
    .pm-tools {
        width: 100%;
        flex-wrap: wrap;
    }
    .pm-tool-btn {
        flex: 1 1 180px;
    }
    .leaflet-popup-content { min-width: 245px; }
    .pm-parcel-popup-card { min-width: 245px; }
    .pm-popup-actions { grid-template-columns: 1fr; }
    .pm-plan-title-label { font-size: 12px; padding: 7px 12px; }
    .pm-parcel-number-label { min-width: 24px; height: 24px; font-size: 11px; }
}

.pm-brand-logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    border-radius: 14px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(15,76,129,.08);
    flex: 0 0 auto;
}
.pm-brand-copy { min-width: 0; }

.pm-search-wrap {
    position: relative;
    flex: 1 1 420px;
    max-width: 560px;
    pointer-events: auto;
}

.pm-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(255,255,255,.75);
    box-shadow: var(--pm-shadow);
    backdrop-filter: blur(14px);
    border-radius: 18px;
    padding: 8px;
}
.pm-search-box input {
    width: 100%;
    min-width: 0;
    height: 42px;
    border: 0;
    outline: none;
    border-radius: 12px;
    background: #f4f8fb;
    color: var(--pm-text);
    font-family: inherit;
    font-size: 13px;
    padding: 0 14px;
}
.pm-search-box button {
    flex: 0 0 auto;
    height: 42px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-dark));
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    padding: 0 16px;
    cursor: pointer;
}

.pm-search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    background: rgba(255,255,255,.98);
    border: 1px solid rgba(15,76,129,.08);
    box-shadow: var(--pm-shadow);
    border-radius: 16px;
    overflow: hidden;
    max-height: 360px;
    overflow-y: auto;
}
.pm-search-item {
    width: 100%;
    display: flex;
    gap: 10px;
    align-items: center;
    border: 0;
    border-bottom: 1px solid rgba(15,76,129,.06);
    background: transparent;
    padding: 11px 12px;
    text-align: right;
    cursor: pointer;
    font-family: inherit;
}
.pm-search-item:last-child { border-bottom: 0; }
.pm-search-item:hover { background: #f7fafc; }
.pm-search-item-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 28px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
}
.pm-search-item-kind-parcel { background: rgba(240,180,41,.18); color: #7a5a11; }
.pm-search-item-kind-property { background: rgba(15,76,129,.12); color: var(--pm-primary-dark); }
.pm-search-item-copy { display: flex; flex-direction: column; min-width: 0; }
.pm-search-item-copy strong {
    color: var(--pm-text);
    font-size: 13px;
    line-height: 1.4;
}
.pm-search-item-copy small {
    color: var(--pm-muted);
    font-size: 11px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pm-search-empty {
    padding: 14px;
    text-align: center;
    color: var(--pm-muted);
    font-size: 12px;
}

.pm-legend {
    position: fixed;
    left: 18px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 799;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(255,255,255,.75);
    box-shadow: var(--pm-shadow);
    font-size: 12px;
    pointer-events: none;
}
.pm-dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 50%;
    margin-left: 6px;
}
.pm-dot-parcel { background: #f0b429; border: 1px solid #b17c00; }
.pm-dot-property { background: #0f4c81; }

.pm-property-marker-icon {
    background: transparent;
    border: 0;
}
.pm-property-marker-dot {
    position: relative;
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: #0f4c81;
    box-shadow: 0 4px 12px rgba(15,76,129,.35);
    border: 2px solid #fff;
}
.pm-property-marker-dot::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    top: 4px;
    left: 4px;
}

.pm-property-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-dark));
    text-decoration: none;
    font-size: 12px;
    font-weight: 900;
}
.pm-property-footer {
    padding: 0 14px 14px;
    background: #fff;
}

@media (max-width: 1120px) {
    .pm-topbar { flex-wrap: wrap; }
    .pm-search-wrap { order: 3; max-width: none; width: 100%; }
}

@media (max-width: 860px) {
    .pm-brand-logo { width: 44px; height: 44px; border-radius: 10px; }
    .pm-search-box { width: 100%; }
    .pm-search-box input { height: 40px; font-size: 12px; }
    .pm-search-box button { height: 40px; }
    .pm-legend {
        left: 12px;
        bottom: 86px;
        right: 12px;
        width: fit-content;
        max-width: calc(100% - 24px);
        flex-wrap: wrap;
        border-radius: 16px;
    }
}

/* v5 filters + better property cards */
.pm-filters {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 6px;
    margin-top: 8px;
    padding: 8px;
    border-radius: 18px;
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(255,255,255,.75);
    box-shadow: var(--pm-shadow);
    backdrop-filter: blur(14px);
}
.pm-filters select,
.pm-filters input,
.pm-filters button {
    height: 36px;
    min-width: 0;
    border: 0;
    outline: none;
    border-radius: 11px;
    background: #f4f8fb;
    color: var(--pm-text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    padding: 0 10px;
}
.pm-filters button {
    cursor: pointer;
    background: #eef5fb;
    color: var(--pm-primary-dark);
    font-weight: 900;
}

.pm-search-item {
    align-items: stretch;
    gap: 8px;
}
.pm-search-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    text-align: right;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
}
.pm-search-share {
    flex: 0 0 auto;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-primary-dark));
    color: #fff;
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    padding: 0 10px;
    cursor: pointer;
}

.pm-property-image {
    width: 100%;
    height: 150px;
    display: block;
    object-fit: cover;
    background: #eef3f8;
}
.pm-property-rows {
    grid-template-columns: 1fr 1fr;
}
.pm-property-rows .pm-popup-row {
    grid-template-columns: 1fr;
    gap: 4px;
}
.pm-property-rows .pm-popup-row-wide {
    grid-column: 1 / -1;
}
.pm-property-rows .pm-popup-value {
    max-width: none;
}
.pm-property-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.pm-property-actions .pm-property-link,
.pm-property-actions button {
    min-height: 38px;
}
.pm-property-link-soft {
    background: #eef5fb;
    color: var(--pm-primary-dark);
}
.pm-property-actions .pm-share-btn,
.pm-property-actions .pm-copy-btn {
    padding: 10px;
}

.leaflet-overlay-pane svg,
.leaflet-overlay-pane canvas,
.leaflet-interactive {
    pointer-events: auto !important;
}

@media (max-width: 860px) {
    .pm-filters {
        grid-template-columns: 1fr 1fr;
    }
    .pm-filters button {
        grid-column: 1 / -1;
    }
    .pm-property-image {
        height: 130px;
    }
}

/* v7: brand opens the platform directly; storage/export buttons are removed from the interface */
.pm-brand-link {
    color: inherit;
    text-decoration: none;
}
.pm-brand-link:hover {
    transform: translateY(-1px);
}
.pm-brand-link:active {
    transform: translateY(0);
}
