html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Arial, sans-serif;
    background: #f8fafc;
    color: #111827;
}

#map {
    height: 100vh;
}

/* ===== MAP LAYER BUTTON ===== */
.map-layer-toggle {
    position: absolute;
    bottom: 50px;
    left: 15px;
    width: 46px;
    height: 46px;
    background: rgba(255, 255, 255, 0.96);
    color: #1f2937;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    cursor: pointer;
    z-index: 2000;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow:
        0 8px 24px rgba(15, 23, 42, 0.16),
        0 2px 6px rgba(15, 23, 42, 0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.map-layer-toggle:hover {
    transform: translateY(-1px);
    box-shadow:
        0 10px 28px rgba(15, 23, 42, 0.18),
        0 3px 8px rgba(15, 23, 42, 0.1);
}

/* ===== POPUP CHỌN BẢN ĐỒ ===== */
.map-layer-popup {
    position: absolute;
    bottom: 102px;
    left: 56px;
    width: 320px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 18px;
    padding: 16px;
    z-index: 2000;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow:
        0 18px 40px rgba(15, 23, 42, 0.18),
        0 4px 12px rgba(15, 23, 42, 0.08);
    display: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.map-layer-popup.active {
    display: block;
}

.map-layer-header {
    font-weight: 700;
    margin-bottom: 12px;
    font-size: 16px;
    color: #111827;
}

.map-layer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.map-layer-item {
    text-align: center;
    cursor: pointer;
    border-radius: 14px;
    padding: 8px;
    transition: background 0.18s ease, transform 0.18s ease;
}

.map-layer-item:hover {
    background: #f8fafc;
    transform: translateY(-1px);
}

.map-layer-item span {
    display: block;
    font-size: 13px;
    margin-top: 6px;
    font-weight: 600;
    color: #374151;
}

.map-close-btn {
    position: absolute;
    right: 12px;
    top: 10px;
    cursor: pointer;
    font-size: 16px;
    color: #6b7280;
    transition: 0.2s;
}

.map-close-btn:hover {
    color: #ef4444;
    transform: scale(1.15);
}

/* ===== LOCATION PANEL ===== */
.location-panel {
    position: fixed;
    bottom: -320px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 26px rgba(15, 23, 42, 0.2);
    z-index: 2000;
    transition: 0.35s;
    padding: 16px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-bottom: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.location-panel.active {
    bottom: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    margin-bottom: 10px;
    color: #111827;
}

.panel-header button {
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: #6b7280;
}

/* ===== PARCEL CONTENT ===== */
.bar-content {
    display: grid;
    grid-template-columns: repeat(4, minmax(80px, 1fr));
    gap: 7px;
    align-items: start;
}

.bar-item {
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 12px;
    padding: 10px 12px;
}

.bar-item span {
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 700;
}

.bar-item b {
    display: block;
    font-size: 14px;
    color: #111827;
    font-weight: 700;
    word-break: break-word;
}

.bar-item.owner {
    grid-column: span 2;
}

.bar-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

/* ===== BUTTON ===== */
.btn {
    border: none;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
    color: #fff;
    font-weight: 700;
    transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.btn:hover {
    opacity: 0.96;
    transform: translateY(-1px);
}

.green {
    background: linear-gradient(180deg, #22c55e, #15803d);
}

.purple {
    background: linear-gradient(180deg, #9333ea, #6b21a8);
}

.indigo {
    background: linear-gradient(180deg, #6366f1, #4338ca);
}

.yellow {
    background: linear-gradient(180deg, #facc15, #eab308);
    color: #111827;
}

/* =========================
MARKER GHIM
========================= */
.marker {
    width: 20px;
    height: 20px;
    background: #1a73e8;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow:
        0 4px 12px rgba(26, 115, 232, 0.35),
        0 2px 5px rgba(0, 0, 0, 0.12);
    position: relative;
}

.marker::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* =========================
MAPLIBRE POPUP
========================= */
.maplibregl-popup {
    max-width: 280px !important;
    z-index: 9999;
}

.maplibregl-popup-content {
    padding: 0 !important;
    border-radius: 16px !important;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.98) !important;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18) !important;
    border: 1px solid rgba(15, 23, 42, 0.06);
    font-family: Arial, sans-serif;
}

.maplibregl-popup-tip {
    border-top-color: #fff !important;
}

.maplibregl-popup-close-button {
    width: 28px !important;
    height: 28px !important;
    line-height: 28px !important;
    font-size: 18px !important;
    color: #6b7280 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 50% !important;
    top: 6px !important;
    right: 8px !important;
    z-index: 2;
}

.maplibregl-popup-close-button:hover {
    background: #f3f4f6 !important;
    color: #111827 !important;
}

/* =========================
POPUP GHIM MINI
========================= */
.gm-popup {
    width: 260px;
    max-width: 100%;
    font-family: system-ui, Arial, sans-serif;
    color: #202124;
}

.gm-popup-head {
    font-size: 14px;
    font-weight: 700;
    padding: 10px 12px 6px;
    border-bottom: 1px solid #eef2f7;
}

.gm-popup-loading {
    padding: 10px 12px;
    font-size: 13px;
    color: #6b7280;
}

.gm-popup-body {
    padding: 8px 12px 10px;
    font-size: 13px;
}

.gm-popup-row {
    margin-bottom: 8px;
    line-height: 1.4;
}

.gm-popup-row:last-child {
    margin-bottom: 0;
}

.gm-popup-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    margin-bottom: 2px;
}

.gm-popup-address {
    font-size: 12.5px;
    color: #3c4043;
    word-break: break-word;
}

.gm-popup-coord {
    font-family: monospace;
    font-size: 12px;
    color: #111;
}

.gm-popup-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.gm-popup-btn {
    flex: 1;
    height: 34px;
    border: none;
    border-radius: 10px;
    font-size: 7px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gm-popup-btn.primary {
    background: #1a73e8;
    color: #fff;
}

.gm-popup-btn.primary:hover {
    background: #1666c1;
}

.gm-popup-btn.gray {
    background: #f1f3f4;
    color: #202124;
}

.gm-popup-btn.gray:hover {
    background: #e4e7e9;
}

/* =========================
LABEL THỬA
========================= */
.pointLabel {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 6px;
    font-weight: 700;
    border: 1px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* ===== ĐỈNH CHUẨN ĐỊA CHÍNH ===== */
.vertexLabel {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    color: #fff;
    border: 2px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    font-family: Arial, sans-serif;
    line-height: 1;
    letter-spacing: -0.1px;
    box-shadow:
        0 2px 8px rgba(37, 99, 235, 0.35),
        0 1px 2px rgba(0, 0, 0, 0.12);
    user-select: none;
    transform-origin: center center;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        opacity 0.18s ease;
}

.vertexLabel.clickable {
    cursor: pointer;
    pointer-events: auto;
}

.vertexLabel.clickable:hover {
    transform: scale(1.08);
    box-shadow:
        0 4px 12px rgba(37, 99, 235, 0.42),
        0 2px 4px rgba(0, 0, 0, 0.14);
}

.vertexLabel.selected {
    background: linear-gradient(180deg, #ef4444, #dc2626) !important;
    border-color: #ffffff !important;
    transform: scale(1.18);
    box-shadow:
        0 6px 16px rgba(220, 38, 38, 0.38),
        0 2px 4px rgba(0, 0, 0, 0.16);
}

.vertexLabel.selected:hover {
    transform: scale(1.18);
}

.edgeMarker {
    pointer-events: none;
    user-select: none;
}

.edgeLabel {
    background: #ffffff;
    color: #dc2626;
    border: 1.5px solid #ef4444;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 11px;
    font-weight: 800;
    font-family: Arial, sans-serif;
    line-height: 1;
    white-space: nowrap;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.12),
        0 1px 2px rgba(0, 0, 0, 0.06);
    transform-origin: center center;
    user-select: none;
}

.areaLabel {
    background: rgba(255, 255, 255, 0.88);
    color: #111827;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 10px 14px;
    min-width: 170px;
    text-align: center;
    font-family: Arial, sans-serif;
    user-select: none;
    box-shadow:
        0 10px 28px rgba(15, 23, 42, 0.16),
        0 2px 6px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.areaLabel .areaLine:first-child {
    font-size: 15px;
    font-weight: 800;
    color: #111827;
    margin-bottom: 3px;
}

.areaLabel .areaLine:last-child {
    font-size: 12px;
    font-weight: 700;
    color: #4b5563;
}

/* =========================
PARCEL BAR
========================= */
.parcel-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -14px 34px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.28s ease;
}

.parcel-bar.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.parcel-bar.collapsed .parcel-bar-body {
    display: none;
}

.parcel-bar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 18px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #fff;
    cursor: pointer;
    user-select: none;
}

.parcel-bar-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.parcel-bar-arrow {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    font-size: 15px;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.parcel-bar.collapsed .parcel-bar-arrow {
    transform: rotate(180deg);
}

.parcel-bar-body {
     padding: 8px 10px 13px;
}

/* =========================
MEASURE POINT
========================= */
.measure-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #1a73e8;
    border: 3px solid #ffffff;
    box-shadow:
        0 2px 8px rgba(26, 115, 232, 0.45),
        0 0 0 1px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.measure-marker:hover {
    transform: scale(1.12);
    box-shadow:
        0 4px 12px rgba(26, 115, 232, 0.5),
        0 0 0 1px rgba(0, 0, 0, 0.08);
}

.measure-marker.start-point {
    width: 16px;
    height: 16px;
    background: #0b57d0;
    border: 3px solid #ffffff;
    box-shadow:
        0 3px 10px rgba(11, 87, 208, 0.5),
        0 0 0 1px rgba(0, 0, 0, 0.08);
}

.measure-marker.last-point {
    width: 16px;
    height: 16px;
    background: #34a853;
    border: 3px solid #ffffff;
    box-shadow:
        0 3px 10px rgba(52, 168, 83, 0.45),
        0 0 0 1px rgba(0, 0, 0, 0.08);
}

.measure-info {
    /* background: #ffffff;
    color: #202124; */
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.16),
        0 1px 2px rgba(0, 0, 0, 0.08);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.maplibregl-canvas-container .maplibregl-marker,
.maplibregl-marker {
    user-select: none;
}

.measure-edge-label {
    background: rgba(255, 255, 255, 0.96);
    color: #202124;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
    white-space: nowrap;
}

/* =========================
HIỆU ỨNG
========================= */
.measure-pulse {
    position: relative;
}

.measure-pulse::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: rgba(26, 115, 232, 0.18);
    z-index: -1;
    animation: measurePulse 1.6s infinite ease-out;
}

@keyframes measurePulse {
    0% {
        transform: scale(0.7);
        opacity: 0.9;
    }
    70% {
        transform: scale(1.45);
        opacity: 0;
    }
    100% {
        transform: scale(1.45);
        opacity: 0;
    }
}

/* =========================
RESPONSIVE
========================= */
@media (max-width: 768px) {
    .map-layer-toggle {
        width: 42px;
        height: 42px;
        font-size: 19px;
        left: 12px;
        bottom: 46px;
    }

    .map-layer-popup {
        width: calc(100vw - 80px);
        max-width: 300px;
        left: 52px;
        bottom: 94px;
        padding: 14px;
    }

    .bar-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .bar-item {
        padding: 8px 10px;
        border-radius: 10px;
    }

    .bar-item.owner {
        grid-column: 1 / -1;
    }

    .bar-actions {
        grid-column: 1 / -1;
    }

    .bar-item span {
        font-size: 10px;
    }

    .bar-item b {
        font-size: 13px;
    }

    .parcel-bar {
        border-radius: 18px 18px 0 0;
    }

    .parcel-bar-head {
        padding: 10px 12px;
    }

    .parcel-bar-title {
        font-size: 14px;
    }

    .parcel-bar-arrow {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }

    .parcel-bar-body {
        padding: 12px;
    }

    .maplibregl-popup {
        max-width: 90vw !important;
    }

    .gm-popup {
        width: min(260px, 90vw);
    }

    .gm-popup-head {
        font-size: 13px;
        padding: 8px 10px 6px;
    }

    .gm-popup-body {
        padding: 8px 10px;
        font-size: 12.5px;
    }

    .gm-popup-label {
        font-size: 10px;
    }

    .gm-popup-address,
    .gm-popup-coord {
        font-size: 12px;
    }

    .gm-popup-btn {
        height: 32px;
        font-size: 11.5px;
    }

    .maplibregl-popup-close-button {
        width: 26px !important;
        height: 26px !important;
        line-height: 26px !important;
        font-size: 16px !important;
    }

    .vertexLabel {
        width: 20px;
        height: 20px;
        font-size: 9px;
    }

    .vertexLabel.selected {
        transform: scale(1.14);
    }

    .edgeLabel {
        font-size: 10px;
        padding: 2px 6px;
    }

    .areaLabel {
        min-width: 145px;
        padding: 8px 10px;
        border-radius: 14px;
    }

    .areaLabel .areaLine:first-child {
        font-size: 13px;
    }

    .areaLabel .areaLine:last-child {
        font-size: 11px;
    }
}