/* ── Control buttons ─────────────────────────────────────────────────────── */

.msr-control.leaflet-bar {
    border: none;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
}

.msr-control.leaflet-bar .msr-btn {
    display: block;
    min-width: 52px;
    height: 26px;
    padding: 0 10px;
    line-height: 26px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    color: #333333;
    background: #ffffff;
    border-bottom: 1px solid #cccccc;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.15s ease, color 0.15s ease;
}

.msr-control.leaflet-bar .msr-btn:last-child {
    border-bottom: none;
}

.msr-control.leaflet-bar .msr-btn:hover {
    background: #f0f4fc;
    color: #1f4b99;
}

.msr-control.leaflet-bar .msr-btn.is-active {
    background: #1f4b99;
    color: #ffffff;
}

/* ── Cursor while measuring ──────────────────────────────────────────────── */

.msr-active,
.msr-active .leaflet-interactive {
    cursor: crosshair !important;
}

/* ── Hover tooltip (follows cursor) ─────────────────────────────────────── */

.leaflet-tooltip.msr-tip {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #b0bdd0;
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 13px;
    font-weight: 500;
    color: #16243a;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(18, 31, 53, 0.14);
    pointer-events: none;
}

.leaflet-tooltip.msr-tip.leaflet-tooltip-top::before {
    border-top-color: #b0bdd0;
}

/* ── Segment distance labels ─────────────────────────────────────────────── */

.leaflet-tooltip.msr-seg-tip {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #99afc8;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 11px;
    font-weight: 600;
    color: #1f4b99;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: none;
}

.leaflet-tooltip.msr-seg-tip::before {
    display: none;
}

/* ── HUD — live info panel during measurement ────────────────────────────── */

.msr-hud {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #b0bdd0;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: #16243a;
    box-shadow: 0 2px 10px rgba(18, 31, 53, 0.15);
    pointer-events: none;
    white-space: nowrap;
    line-height: 1.4;
}

.msr-hud[hidden] {
    display: none;
}

/* ── Backdrop — catches clicks outside the final dialog ──────────────────── */

.msr-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1199;
    background: transparent;
    cursor: default;
}

/* ── Final dialog ────────────────────────────────────────────────────────── */

.msr-dialog {
    position: fixed;
    bottom: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    min-width: 240px;
    max-width: 320px;
    width: max-content;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(18, 31, 53, 0.22);
    overflow: hidden;
    pointer-events: auto;
}

.msr-dialog__title {
    padding: 13px 16px 11px;
    font-size: 14px;
    font-weight: 700;
    color: #16243a;
    background: #f6f8fb;
    border-bottom: 1px solid #dce3ef;
}

.msr-dialog__results {
    padding: 12px 16px 10px;
    font-size: 13px;
    color: #16243a;
    line-height: 1.65;
}

.msr-dialog__row {
    margin-bottom: 1px;
}

.msr-dialog__segments {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eef2f7;
    font-size: 12px;
    color: #53627a;
    line-height: 1.6;
}

.msr-dialog__seg-row {
    padding: 0;
}

.msr-dialog__actions {
    display: flex;
    gap: 8px;
    padding: 10px 16px 12px;
    border-top: 1px solid #dce3ef;
    background: #f6f8fb;
}

.msr-dialog__btn {
    flex: 1;
    height: 34px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
    border: 1px solid #d6dfed;
}

.msr-dialog__btn--save {
    background: #1f4b99;
    color: #ffffff;
    border-color: #1f4b99;
}

.msr-dialog__btn--save:hover {
    background: #173a79;
    border-color: #173a79;
}

.msr-dialog__btn--discard {
    background: #ffffff;
    color: #16243a;
}

.msr-dialog__btn--discard:hover {
    background: #f0f4fc;
}

/* ── Popup for saved measurements ────────────────────────────────────────── */

.msr-popup {
    font-size: 13px;
    line-height: 1.65;
    color: #16243a;
    min-width: 160px;
}

.msr-popup__title {
    font-size: 14px;
    font-weight: 700;
    color: #1f4b99;
    margin-bottom: 6px;
}

.msr-popup__row {
    margin-bottom: 1px;
}

.msr-popup__segments {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eef2f7;
    font-size: 12px;
    color: #53627a;
}

.msr-popup__seg-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 1px 0;
}
