* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100vw;
    overscroll-behavior-x: none;
}

body {
    font-family: 'Trebuchet MS', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-x: hidden;
    max-width: 100vw;
    overscroll-behavior-x: none;
}

/* Session Loading Overlay */
.session-loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.session-loading-overlay.visible {
    display: flex;
}

.session-loading-card {
    background: white;
    border-radius: 12px;
    padding: 32px 48px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.session-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: #0933AB;
    border-radius: 50%;
    animation: session-spin 0.8s linear infinite;
}

@keyframes session-spin {
    to {
        transform: rotate(360deg);
    }
}

.session-loading-text {
    font-size: 16px;
    font-weight: 500;
    color: #4a5568;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    overflow: hidden;
}

/* Route Panel */
.route-panel {
    position: absolute;
    top: 68px;
    left: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    width: 400px;
    z-index: 1;
    max-height: calc(100vh - 140px); /* Leave space for vehicle panel above and legend below */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.route-panel::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

.route-panel-header {
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    min-height: 20px;
    position: relative;
}

.route-panel-header h2 {
    font-size: 17px;
    margin: 0;
    color: #333;
    font-weight: 600;
    flex: 1;
}

.route-panel-header h2.panel-title-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.panel-title-text {
    display: inline-block;
    min-width: 95px;
}

.route-panel-arrow {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s;
}

.route-panel-content {
    padding: 15px;
    display: none;
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.route-panel.expanded .route-panel-content {
    display: block;
}


.route-panel.expanded .route-panel-header {
    border-bottom: 1px solid #eee;
}

.route-panel:not(.expanded) .route-panel-header {
    border-bottom: none;
}

/* ====== Search mode (initial state) ====== */
.route-search-mode { display: none; }
.route-panel.search-mode .route-search-mode { display: block; }

.route-panel.search-mode #waypointsContainer,
.route-panel.search-mode .route-controls-row,
.route-panel.search-mode #routeObjectsContainer,
.route-panel.search-mode #modeIndicator { display: none !important; }

/* Search mode header */
.search-mode-title {
    display: none;
    font-size: 14px;
    font-weight: 500;
    color: #555;
}
.route-panel.search-mode .search-mode-title { display: inline; }
.route-panel.search-mode .route-coords-badge { display: none !important; }

/* Highlight build-route button when search result is selected */
.route-btn.search-ready {
    background: #0933AB !important;
    color: white !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

/* In search mode, keep button but style it as disabled until result selected */
.route-panel.search-mode .route-btn.primary:not(.search-ready) {
    opacity: 0.5;
    cursor: default;
}

/* Allow dropdown to overflow panel in search mode */
.route-panel.search-mode {
    overflow: visible;
}
.route-panel.search-mode .route-panel-content {
    overflow: visible;
}

.route-search-wrapper {
    position: relative;
}

.route-search-input {
    width: 100%;
    padding: 10px 68px 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    background: #f7fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.route-search-input:focus {
    border-color: #0933AB;
    outline: none;
    box-shadow: 0 0 0 2px rgba(9, 51, 171, 0.15);
    background: white;
}

.route-search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: #0933AB;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.route-search-btn:hover {
    background: #0a2a8a;
}

.route-search-clear {
    position: absolute;
    right: 38px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    background: none;
    border: none;
    font-size: 18px;
    color: #a0aec0;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

.route-search-clear:hover {
    color: #333;
}

.route-search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 350px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}

.route-search-dropdown.visible {
    display: block;
}

.route-search-section-header {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #a0aec0;
    text-transform: uppercase;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.route-search-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.route-search-item:last-child {
    border-bottom: none;
}

.route-search-item:hover {
    background: #f7fafc;
}

.route-search-item-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-search-item-subtitle {
    font-size: 11px;
    color: #718096;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-search-empty {
    padding: 16px 12px;
    text-align: center;
    color: #a0aec0;
    font-size: 13px;
}

.route-search-loading {
    padding: 12px;
    text-align: center;
    color: #718096;
    font-size: 13px;
}
/* ====== End search mode ====== */

.route-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.route-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s;
}

.route-btn.primary {
    background: #3498db;
    color: white;
}

.route-btn.primary:hover {
    background: #2980b9;
}

.route-btn.primary:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.route-btn.secondary {
    background: #ecf0f1;
    color: #333;
}

.route-btn.secondary:hover {
    background: #dde4e6;
}

/* Vehicle Panel */
.vehicle-panel {
    position: absolute;
    top: 8px;
    left: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    width: 400px;
    z-index: 2;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
}

/* When SR button is visible, shift main panels down (not segment-pair panels) */
body.has-sr-button #vehiclePanel {
    top: 56px !important;
}

/* Route panel position is set dynamically by updateRoutePanelPosition() */

.vehicle-panel-header {
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    min-height: 20px;
    position: relative;
}

.vehicle-panel-header h2 {
    font-size: 17px;
    margin: 0;
    color: #333;
    font-weight: 600;
}

.vehicle-panel-header h2.panel-title-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.vehicle-icon {
    width: 55px;
    height: 55px;
    flex-shrink: 0;
    padding: 3px;
}

.route-icon {
    width: 55px;
    height: 55px;
    flex-shrink: 0;
    padding: 3px;
}

.vehicle-params-badge {
    display: flex;
    align-items: center;
    gap: 0;
    font-family: 'Trebuchet MS', Arial, sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #4a5568;
}

.route-distance {
    font-size: 14px;
    font-weight: bold;
    margin-left: auto;
    margin-right: 35px;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 6px;
    transition: background-color 0.15s;
}

.route-distance:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

.route-coords-badge {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    font-family: 'Trebuchet MS', Arial, sans-serif;
    font-size: 15px;
    font-weight: 400;
    color: #4a5568;
}

.panel-title-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.param-box, .coord-box {
    display: inline-block;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 16px;
    font-weight: 400;
    position: relative;
    cursor: default;
}

.param-box.editable-param {
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.param-box.editable-param:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.param-box[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: normal;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
    margin-bottom: 4px;
    z-index: 1000;
}

.param-box[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

.param-separator {
    font-size: 15px;
    font-weight: 400;
    color: #718096;
    padding: 0;
}

.route-coords-badge {
    cursor: default;
}

.coord-box {
    cursor: pointer;
}
.coord-box:hover {
    background: #edf2f7;
}

/* Colored coordinate badges with custom tooltip */
.coord-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: opacity 0.2s, filter 0.2s;
    position: relative;
}
.coord-badge:hover {
    opacity: 0.85;
    filter: brightness(1.1);
}
.coord-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 0;
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: normal;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    margin-bottom: 4px;
    z-index: 1000;
}
.coord-badge:hover::after {
    opacity: 1;
    visibility: visible;
}
.coord-badge-separator {
    font-size: 14px;
    color: #718096;
    padding: 0 4px;
}

.coord-copy {
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 1px 3px;
    margin: 0 -2px;
    border-radius: 2px;
}

.coord-copy:hover {
    background: #edf2f7;
    color: #2b6cb0;
}

.route-coord-item {
    cursor: pointer;
    transition: background 0.2s;
    padding: 1px 2px;
    margin: 0 -1px;
    border-radius: 2px;
}

.route-coord-item:hover {
    background: #e2e8f0;
}

.vehicle-panel-arrow,
.route-panel-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #666;
    transition: transform 0.2s;
}

.vehicle-panel.expanded .vehicle-panel-arrow,
.route-panel.expanded .route-panel-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* Minimized state - only icon visible */
.vehicle-panel.minimized .vehicle-params-badge,
.vehicle-panel.minimized .vehicle-panel-arrow,
.route-panel.minimized .route-coords-badge,
.route-panel.minimized .route-distance,
.route-panel.minimized .route-panel-arrow {
    display: none !important;
}

.vehicle-panel.minimized,
.route-panel.minimized {
    width: fit-content !important;
    min-width: auto !important;
    max-width: fit-content !important;
}

.vehicle-panel.minimized .vehicle-panel-header,
.route-panel.minimized .route-panel-header {
    padding: 4px 6px;
}

.vehicle-panel.minimized .panel-title-wrap,
.route-panel.minimized .panel-title-wrap {
    gap: 0;
}

/* Panel dimming overlay (desktop only) */
@media (min-width: 769px) {
    .route-panel::after,
    .vehicle-panel::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
        z-index: 100;
    }

    /* When any panel is expanded, dim collapsed panels */
    body.has-expanded-panel .route-panel:not(.expanded)::after,
    body.has-expanded-panel .vehicle-panel:not(.expanded)::after {
        opacity: 1;
    }

    /* When multiple panels expanded, dim those not hovered */
    body.has-multiple-expanded .route-panel.expanded:not(:hover)::after,
    body.has-multiple-expanded .vehicle-panel.expanded:not(:hover)::after {
        opacity: 1;
    }

    /* Never dim the hovered panel */
    .route-panel:hover::after,
    .vehicle-panel:hover::after {
        opacity: 0 !important;
    }
}

.vehicle-icon,
.route-icon {
    cursor: pointer;
}

.vehicle-panel-content {
    padding: 15px;
    display: none;
    background: #f7fafc;
}

.vehicle-panel.expanded .vehicle-panel-content {
    display: block;
}


.vehicle-panel.expanded .vehicle-panel-header {
    border-bottom: 1px solid #eee;
}

.vehicle-panel:not(.expanded) .vehicle-panel-header {
    border-bottom: none;
}

.mode-indicator {
    background: #fff3cd;
    color: #856404;
    padding: 8px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 10px;
    display: none;
}

.mode-indicator.active {
    display: block;
}

/* Legend item styles */
.legend-item {
    display: flex;
    align-items: flex-start;
    margin: 6px 0;
    font-size: 14px;
}

.legend-item .legend-color {
    margin-top: 3px;
}

.legend-color {
    width: 24px;
    height: 6px;
    margin-right: 8px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.legend-desc {
    font-size: 11px;
    color: #888;
    font-style: italic;
}

/* Layer toggle */
.layer-toggle {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.layer-toggle label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
}

.layer-toggle input {
    margin-right: 8px;
}

/* Oval toggle switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    margin-left: auto;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #4CAF50;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

.legend-item-toggle {
    display: flex;
    align-items: flex-start;
    margin: 6px 0;
    font-size: 14px;
}

/* Custom tooltips for legend items */
.legend-item-toggle span[data-tooltip] {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted rgba(255,255,255,0.4);
}

.legend-item-toggle span[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    background: #1a1a2e;
    color: #e0e0e0;
    padding: 8px 11px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    width: 240px;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.12);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
}

.legend-item-toggle span[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

.legend-item-toggle .legend-color {
    margin-top: 3px;
}

.legend-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    margin-bottom: 4px;
}

.legend-section-header h3 {
    margin: 0;
    font-size: 14px;
}

.maplibregl-popup-content {
    padding: 12px;
    max-width: 360px;
}

/* Popup close button - enlarged zone */
.maplibregl-popup-close-button {
    width: 28px;
    height: 28px;
    font-size: 20px;
    line-height: 28px;
    text-align: center;
    padding: 0;
    right: 2px;
    top: 2px;
    color: #666;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
}

.maplibregl-popup-close-button:hover {
    background: #f0f0f0;
    color: #333;
}

.popup-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

.popup-field {
    margin: 4px 0;
    font-size: 12px;
    color: #666;
}

.popup-field strong {
    color: #333;
    display: inline-block;
    min-width: 120px;
}

/* Restriction popup pagination */
.popup-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 13px;
}

.popup-pagination .page-num {
    color: #999;
}

.popup-pagination .page-link {
    color: #1976d2;
    cursor: pointer;
    text-decoration: none;
}

.popup-pagination .page-link:hover {
    text-decoration: underline;
}

/* Action button toggle states */
.action-btn.pressed.bypass-btn {
    background: #1976d2 !important;
    color: white !important;
    border-color: #1565c0 !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.action-btn.pressed.cutout-btn {
    background: #f57c00 !important;
    color: white !important;
    border-color: #e65100 !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.action-btn.pressed.delete-btn {
    background: #d32f2f !important;
    color: white !important;
    border-color: #b71c1c !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.loading {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    padding: 8px 16px;
    z-index: 1000;
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0 0 4px rgba(0,0,0,0.5);
    pointer-events: none;
}

/* Vehicle Parameters */
.vehicle-params {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.vehicle-params h3 {
    font-size: 14px;
    color: #333;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.params-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.param-group {
    display: flex;
    flex-direction: column;
}

.param-group.full-width {
    grid-column: 1 / -1;
}

.param-group label {
    font-size: 11px;
    color: #666;
    margin-bottom: 3px;
}

.param-group input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
}

.param-group input:focus {
    outline: none;
    border-color: #3498db;
}

.param-group input::placeholder {
    color: #bbb;
}

/* Axle loads section */
.axle-section {
    margin-top: 10px;
}

.axle-section h4 {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.axle-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.axle-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa;
    padding: 6px 8px;
    border-radius: 4px;
}

.axle-item span {
    font-size: 12px;
    color: #666;
    min-width: 50px;
}

.axle-item input {
    flex: 1;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.axle-item input:focus {
    outline: none;
    border-color: #3498db;
}

.axle-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
}

.axle-remove:hover {
    color: #e74c3c;
}

.add-axle-btn {
    background: #f0f0f0;
    border: 1px dashed #ccc;
    border-radius: 4px;
    padding: 6px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    width: 100%;
    margin-top: 6px;
}

.add-axle-btn:hover {
    background: #e8e8e8;
    border-color: #999;
}

.collapse-toggle {
    background: none;
    border: none;
    color: #3498db;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.collapse-toggle:hover {
    text-decoration: underline;
}

.vehicle-params.collapsed .params-content {
    display: none;
}

.copy-btn {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    margin-left: 6px;
}

.copy-btn:hover {
    background: #bbdefb;
}

/* Waypoint input fields */
.waypoints-inputs {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 12px;
}

#viaInputsContainer {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.waypoint-row {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: visible;
}

.waypoint-row.dragging {
    opacity: 0.6;
    background: #dbeafe;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
}

.waypoint-row.drag-over {
    border-top: 3px solid #4299e1;
    margin-top: -1px;
}

.waypoint-row.drag-over-below {
    border-bottom: 3px solid #4299e1;
    margin-bottom: -1px;
}

/* Cut route button - under via points */
.cut-route-btn {
    /* Match input-wrapper width exactly */
    /* Formula: 100% - (label: 24px + gap: 8px + drag: ~23px + gap: 8px + gap: 8px + action-btn: 28px) */
    width: calc(100% - 99px);
    /* Align with input-wrapper start: label + gap + drag + gap */
    margin-left: 63px;
    padding: 6px 12px;
    margin-top: 0; /* No gap between input and button */
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #f57c00;
    background: #fff3e0;
    color: #f57c00;
    border-radius: 0 0 3px 3px; /* Only bottom corners rounded */
    border-top: none; /* Merge with input above */
    transition: background 0.2s, border-color 0.2s, opacity 0.2s;
    display: none; /* Hidden by default */
}

.cut-route-btn:hover {
    background: #ffe0b2;
    border-color: #e65100;
}

/* Pressed state - stays visible and changes color (like cutout button) */
.cut-route-btn.pressed {
    display: block !important;
    background: #f57c00;
    color: white;
    border-color: #e65100;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.cut-route-btn.pressed:hover {
    background: #ef6c00;
}

/* Show button when input is focused or button itself is hovered */
/* data-point^="via" matches both "via" (main route) and "via-0", "via-1" (sub-routes) */
.waypoint-row[data-point^="via"]:focus-within + .cut-route-btn,
.cut-route-btn:hover {
    display: block;
}

/* Add shadow to button when input is focused (matches input focus style) */
.waypoint-row[data-point^="via"]:focus-within + .cut-route-btn {
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
    border-color: #4299e1;
}

/* Remove bottom border-radius from via point input only when input is focused (for seamless connection) */
.waypoint-row[data-point^="via"]:focus-within .waypoint-input {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.waypoint-label {
    width: 24px;
    height: 24px;
    background: #4a5568;
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 15px;
    flex-shrink: 0;
}

.waypoint-label.label-a { background: #4a5568; }
.waypoint-label.label-via { background: #718096; }
.waypoint-label.label-b { background: #4a5568; }

.waypoint-drag {
    color: #999;
    cursor: grab;
    font-size: 18px;
    padding: 4px 6px;
    user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
}

.waypoint-drag:hover {
    color: #666;
    background: #f0f0f0;
    border-radius: 4px;
}

.waypoint-drag:active {
    cursor: grabbing;
    color: #333;
}

.waypoint-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    overflow: visible;
}

.waypoint-input {
    width: 100%;
    padding: 10px 32px 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 16px;
    background: #f7fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.waypoint-input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
    background: white;
}

.waypoint-input.has-value {
    background: white;
    color: #2d3748;
}

/* Valid coordinates feedback */
.waypoint-input.valid-coords {
    border-color: #48bb78;
    background: white;
}

.waypoint-input.valid-coords:focus {
    border-color: #48bb78;
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.15);
}

.waypoint-input-wrapper {
    position: relative;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: calc(100% + 5px);
    background: white;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.autocomplete-dropdown.visible {
    display: block;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f7fafc;
}

.autocomplete-item-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.autocomplete-item-text {
    flex: 1;
    overflow: hidden;
}

.autocomplete-item-name {
    font-weight: 500;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-region {
    font-size: 12px;
    color: #718096;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-loading {
    padding: 12px;
    text-align: center;
    color: #718096;
    font-size: 13px;
}

/* Marker pulse animation */
@keyframes marker-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.marker-pulse {
    animation: marker-pulse 0.4s ease-out;
}

.waypoint-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 50%;
    line-height: 1;
    transition: background-color 0.2s, color 0.2s;
}

.waypoint-clear:hover {
    background: #fed7d7;
    color: #c53030;
}

.waypoint-add-btn {
    width: 28px;
    height: 28px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.waypoint-add-btn:hover {
    background: #38a169;
}

.waypoint-add-btn.hidden {
    visibility: hidden;
}

.waypoint-delete-btn {
    width: 28px;
    height: 28px;
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.waypoint-delete-btn:hover {
    background: #c53030;
}

/* Via point action button - can be delete (red) or add (green) */
.via-action-btn {
    width: 28px;
    height: 28px;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.via-action-btn.delete {
    background: #e53e3e;
}

.via-action-btn.delete:hover {
    background: #c53030;
}

.via-action-btn.add {
    background: #48bb78;
}

.via-action-btn.add:hover {
    background: #38a169;
}

.waypoint-spacer {
    width: 28px;
    flex-shrink: 0;
}

/* Route controls row */
.route-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
}

.vehicle-dropdown-btn {
    background: none;
    border: none;
    color: #4a5568;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.vehicle-dropdown-btn:hover {
    color: #2d3748;
}

.reset-link {
    background: none;
    border: none;
    color: #718096;
    cursor: pointer;
    font-size: 15px;
    padding: 4px 0;
}

.reset-link:hover {
    color: #e53e3e;
}

/* Vehicle params panel */
.vehicle-params-panel {
    background: #f7fafc;
    border-radius: 6px;
    margin-bottom: 12px;
    display: none;
}

.vehicle-params-panel.visible {
    display: block;
}

.vehicle-params-header {
    padding: 10px 12px;
    font-weight: 600;
    font-size: 15px;
    color: #2d3748;
    border-bottom: 1px solid #e2e8f0;
}

.vehicle-params-content {
    padding: 12px;
}

.params-section {
    margin-bottom: 12px;
}

.params-section:last-child {
    margin-bottom: 0;
}

.params-section-title {
    font-size: 14px;
    color: #718096;
    margin-bottom: 8px;
}

.dimensions-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.dimension-input {
    flex: 1;
    min-width: 0;
    padding: 8px 4px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 15px;
    text-align: center;
    background: white;
}

.dimension-input:focus {
    outline: none;
    border-color: #4299e1;
}

.dimension-separator {
    color: #a0aec0;
    font-size: 14px;
    flex-shrink: 0;
}

.axle-preset-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 15px;
    background: white;
    margin-bottom: 8px;
    text-align: center;
}

.axle-inputs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.axle-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.axle-label {
    font-size: 14px;
    color: #4a5568;
    width: 45px;
    flex-shrink: 0;
}

.axle-input {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
    background: white;
    transition: border-color 0.2s, background-color 0.2s;
}

.axle-input:focus {
    outline: none;
    border-color: #4299e1;
}

.axle-input.axle-error {
    border-color: #e53e3e;
    background-color: #fff5f5;
}

.axle-input.axle-error:focus {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.15);
}

.axle-unit {
    font-size: 13px;
    color: #718096;
    width: 35px;
    flex-shrink: 0;
}

.axle-delete {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e0e0e0;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: #666;
    flex-shrink: 0;
    line-height: 1;
}

.axle-delete:hover {
    background: #ccc;
    color: #e53e3e;
}

.total-mass-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.total-mass {
    font-size: 15px;
    color: #4a5568;
}

.add-axle-link {
    background: none;
    border: none;
    color: #4299e1;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    text-align: right;
}

.add-axle-link:hover {
    text-decoration: underline;
}

/* Address autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: calc(100% + 5px);
    background: white;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 280px;
    overflow-y: auto;
    display: none;
}

.autocomplete-dropdown.visible {
    display: block;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f0f7ff;
}

.autocomplete-item-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    padding-top: 2px;
}

.autocomplete-item-content {
    flex: 1;
    min-width: 0;
}

.autocomplete-item-name {
    font-size: 14px;
    color: #2d3748;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-address {
    font-size: 12px;
    color: #718096;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-type {
    font-size: 10px;
    color: #a0aec0;
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.autocomplete-loading {
    padding: 12px;
    text-align: center;
    color: #718096;
    font-size: 13px;
}

.autocomplete-empty {
    padding: 12px;
    text-align: center;
    color: #a0aec0;
    font-size: 13px;
}

/* Right-click context menu */
/* Confirmation modal */
.confirm-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.confirm-modal-overlay.visible {
    display: flex;
}

.confirm-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 360px;
    text-align: center;
}

.confirm-modal-text {
    font-size: 16px;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.5;
}

.confirm-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.confirm-modal-btn.confirm {
    background: #e53e3e;
    color: white;
}

.confirm-modal-btn.confirm:hover {
    background: #c53030;
}

.confirm-modal-btn.cancel {
    background: #e2e8f0;
    color: #333;
}

.confirm-modal-btn.cancel:hover {
    background: #cbd5e0;
}

/* Comment modal styles */
.comment-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    justify-content: center;
    align-items: center;
}

.comment-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.comment-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    font-size: 16px;
}

.comment-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0 4px;
}

.comment-modal-close:hover {
    color: #333;
}

.comment-modal-body {
    padding: 20px;
}

.comment-form-group {
    margin-bottom: 16px;
}

.comment-form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.comment-form-group textarea,
.comment-form-group input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.comment-form-group textarea:focus,
.comment-form-group input[type="text"]:focus {
    outline: none;
    border-color: #4a90d9;
}

.comment-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.comment-modal-info {
    font-size: 12px;
    color: #888;
    text-align: center;
    padding: 8px;
    background: #fafafa;
    border-radius: 4px;
}

.comment-modal-buttons {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
}

.comment-modal-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

.comment-modal-btn.submit {
    background: #4a90d9;
    color: white;
}

.comment-modal-btn.submit:hover {
    background: #3a7bc8;
}

.comment-modal-btn.submit:disabled {
    background: #a0c4e8;
    cursor: not-allowed;
}

.comment-modal-btn.cancel {
    background: #e2e8f0;
    color: #333;
}

.comment-modal-btn.cancel:hover {
    background: #cbd5e0;
}

/* Comments section in popups */
.comments-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #ddd;
}

.comments-section-title {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.comment-item {
    background: #f5f7fa;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 13px;
}

.comment-item:last-child {
    margin-bottom: 0;
}

.comment-author {
    font-weight: 500;
    color: #4a90d9;
    font-size: 12px;
}

.comment-date {
    font-size: 11px;
    color: #999;
    margin-left: 8px;
}

.comment-text {
    margin-top: 4px;
    color: #333;
    line-height: 1.4;
}

.coord-context-menu {
    position: fixed;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    padding: 4px 0;
    z-index: 1000;
    min-width: 180px;
}

.coord-context-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.coord-context-menu-item:hover {
    background: #f5f5f5;
}

.coord-context-menu-coords {
    padding: 6px 12px;
    font-size: 14px;
    color: #666;
    font-family: monospace;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
}

/* Validation error */
.validation-error,
input.validation-error {
    border-color: #e74c3c !important;
    background-color: #fff5f5 !important;
}

.axle-list.validation-error .axle-item input {
    border-color: #e74c3c;
    background-color: #fff5f5;
}

/* Send to safe-route button - above panels */
/* Top action buttons container */
.top-action-buttons {
    display: none;
    position: absolute;
    top: 8px;
    left: 8px;
    width: 400px;
    gap: 6px;
    z-index: 5;
}

.top-action-buttons.visible {
    display: flex;
}

.send-to-sr-btn {
    display: none;
    flex: 2;
    padding: 10px 16px;
    background: #0933AB;
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background 0.2s;
}

.send-to-sr-btn:hover {
    background: #072a8a;
}

.send-to-sr-btn.visible {
    display: block;
}

.share-floating-btn {
    display: none;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: #7c3aed;
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background 0.2s;
}

.share-floating-btn:hover {
    background: #6d28d9;
}

.share-floating-btn .share-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Undo button - inside route panel */
.undo-btn {
    display: none;
    background: #546e7a;
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    padding: 10px 16px;
    border-radius: 6px;
    margin-top: 10px;
    gap: 6px;
}
.undo-btn.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}
.undo-btn:hover {
    background: #455a64;
}
.undo-btn:active {
    transform: scale(0.97);
}
.undo-icon {
    font-size: 16px;
}

/* Reset all button - inside route panel */
.reset-all-btn {
    display: none;
    background: #d32f2f;
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    padding: 10px 16px;
    border-radius: 6px;
    margin-top: 10px;
}

.reset-all-btn:hover {
    background: #b71c1c;
}

.reset-all-btn.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.reset-all-btn .reset-text {
    display: inline;
}

.reset-all-btn .reset-icon {
    display: none;
    font-size: 22px;
    font-weight: bold;
}

/* Minimized state - match minimized panel icon size */
.reset-all-btn.minimized {
    width: auto;
    height: auto;
    padding: 4px 6px;
    min-width: 67px;
    min-height: 63px;
}

.reset-all-btn.minimized .reset-text {
    display: none;
}

.reset-all-btn.minimized .reset-icon {
    display: inline;
    font-size: 28px;
}

/* Segment panels container - allow clicks to pass through to map */
#segmentPanelsContainer {
    pointer-events: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#segmentPanelsContainer::-webkit-scrollbar {
    display: none;
}

/* Panels and buttons inside container should capture clicks */
#segmentPanelsContainer .segment-pair,
#segmentPanelsContainer .vehicle-panel,
#segmentPanelsContainer .route-panel,
#segmentPanelsContainer .undo-btn,
#segmentPanelsContainer .reset-all-btn,
#segmentPanelsContainer .import-sr-btn,
#segmentPanelsContainer .add-route-btn {
    pointer-events: auto;
}

/* Vertical label for minimized sub-route pairs - appears on RIGHT */
.segment-label {
    position: absolute;
    right: -22px;
    top: 0;
    width: 28px;
    border-radius: 8px 0 0 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    transform: rotate(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 2px;
    box-sizing: border-box;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

/* Segment pair - vehicle panel above route panel */
.segment-pair {
    display: flex;
    flex-direction: column;
    gap: 0; /* panels touch each other */
}

/* Panels inside segment-pair use relative positioning - high specificity to override all */
.segment-pair .vehicle-panel,
.segment-pair .route-panel,
body.has-sr-button .segment-pair .vehicle-panel,
body.has-sr-button .segment-pair .route-panel {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Visual overlap: vehicle panel extends down, route panel overlaps it (DESKTOP ONLY) */
@media (min-width: 769px) {
    .segment-pair .vehicle-panel {
        padding-bottom: 30px !important;
        margin-bottom: -22px !important;
        z-index: 1 !important;
    }

    .segment-pair .route-panel {
        z-index: 2 !important;
    }
}

.segment-pair.both-minimized .segment-label {
    opacity: 1;
}

.segment-pair.both-minimized {
    width: fit-content;
}

/* Legend panel - icon in bottom right */
.legend-panel {
    position: absolute;
    bottom: 8px;
    right: 8px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.legend-icon-btn {
    width: 55px;
    height: 55px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: background 0.2s;
}

.legend-icon-btn:hover {
    background: #f5f5f5;
}

.legend-icon-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.legend-content {
    display: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    padding: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    width: 400px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.legend-panel.expanded .legend-content {
    display: block;
}

.legend-content h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #666;
    font-weight: 600;
}

/* Horizontal zoom controls */
.zoom-controls-horizontal {
    display: flex;
    gap: 4px;
    background: white;
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.zoom-controls-horizontal button {
    width: 34px;
    height: 34px;
    border: none;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.zoom-controls-horizontal button:hover {
    background: #f0f0f0;
}

.zoom-controls-horizontal button:active {
    background: #e0e0e0;
}

/* Legend section headers */
.legend-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.legend-section-title {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    flex-grow: 1;
}

.legend-subsection {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    margin: 8px 0 6px 0;
}

.toggle-hint {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}

/* Red/danger toggle switch */
.toggle-switch.toggle-danger .toggle-slider {
    background-color: #ccc;
}

.toggle-switch.toggle-danger input:checked + .toggle-slider {
    background-color: #d32f2f;
}

/* Legend separator */
.legend-separator {
    height: 1px;
    background: #e0e0e0;
    margin: 12px 0;
}

/* Legend footer links */
.legend-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    margin-top: 4px;
}

.legend-footer a {
    color: #1976d2;
    text-decoration: none;
}

.legend-footer a:hover {
    text-decoration: underline;
}

.legend-footer-divider {
    color: #ccc;
}

.legend-footer-feedback {
    margin-top: 2px;
}

/* Feedback modal */
.feedback-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.feedback-modal {
    background: white;
    border-radius: 12px;
    width: 460px;
    max-width: 92vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.feedback-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #eee;
}

.feedback-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #333;
}

.feedback-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.feedback-close-btn:hover {
    color: #333;
}

.feedback-modal-body {
    padding: 16px 20px 20px;
}

.feedback-textarea {
    width: 100%;
    min-height: 130px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    color: #333;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.feedback-textarea::placeholder {
    color: #9ca3af;
    font-size: 13px;
    line-height: 1.5;
}

.feedback-textarea:focus {
    outline: none;
    border-color: #0933AB;
    box-shadow: 0 0 0 3px rgba(9, 51, 171, 0.1);
}

.feedback-textarea.feedback-error {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.feedback-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.feedback-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.feedback-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feedback-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-thumb-remove:hover {
    background: rgba(0, 0, 0, 0.85);
}

.feedback-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    gap: 12px;
}

.feedback-attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #4a5568;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.feedback-attach-btn:hover {
    background: #f7fafc;
    border-color: #a0aec0;
}

.feedback-send-btn {
    padding: 9px 28px;
    border: none;
    border-radius: 6px;
    background: #0933AB;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.feedback-send-btn:hover {
    background: #072a8a;
}

.feedback-send-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

/* Segments header (shown when route is split) */
.segments-header {
    position: absolute;
    top: 56px;
    left: 8px;
    width: 400px;
    height: 30px;
    z-index: 11;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    box-sizing: border-box;
}

.segments-header-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.segments-header-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f5f5f5;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #333;
    transition: background 0.2s;
}

.segments-header-toggle:hover {
    background: #e0e0e0;
}

.panels-toggle-icon {
    font-weight: bold;
    font-size: 14px;
    transition: transform 0.2s;
}

.segments-header-toggle.collapsed .panels-toggle-icon {
    transform: rotate(180deg);
}

/* Restriction cards in route panel */
.restriction-link {
    color: #1976d2;
    text-decoration: none;
    cursor: pointer;
}

.restriction-link:hover {
    text-decoration: underline;
}

.restriction-item {
    margin: 8px 0;
    padding: 8px 10px;
    background: #fff8e1;
    border-radius: 4px;
    border-left: 3px solid #ff9800;
    font-size: 13px;
}

.restriction-item:hover {
    background: #fff3cd;
}

.restriction-item.blocking {
    background: #ffebee;
    border-left-color: #e53935;
}

.restriction-item.blocking:hover {
    background: #ffcdd2;
}

.control-point-item {
    margin: 8px 0;
    padding: 8px 10px;
    background: #e3f2fd;
    border-radius: 4px;
    border-left: 3px solid #1976d2;
    font-size: 13px;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.control-point-item:hover {
    background: #bbdefb;
}

.route-objects-container {
    margin: 12px 0;
    padding: 0 4px;
}

.route-no-objects {
    color: #4caf50;
    font-size: 13px;
    padding: 4px 0;
}

.route-restrictions-section,
.route-control-points-section {
    margin-bottom: 12px;
}

.route-section-header {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 6px;
    padding: 4px 0;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.route-section-header:hover {
    color: #333;
}

.section-arrow {
    font-size: 10px;
    color: #999;
    margin-left: 8px;
}

.section-content {
    transition: max-height 0.2s ease-out;
}

.section-content.collapsed {
    display: none;
}

.restriction-item .restriction-name {
    font-weight: 500;
    color: #333;
    cursor: pointer;
}

.restriction-item .restriction-details {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.restriction-item .restriction-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.restriction-item .action-btn {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 3px;
    cursor: pointer;
    border: 1px solid;
}

.restriction-item .bypass-btn {
    background: #e3f2fd;
    border-color: #1976d2;
    color: #1976d2;
}

.restriction-item .delete-btn {
    background: #ffebee;
    border-color: #d32f2f;
    color: #d32f2f;
}

.control-point-item .cp-type {
    font-weight: 600;
    margin-bottom: 2px;
}

.control-point-item .cp-location {
    font-size: 13px;
    color: #333;
}

.control-point-item .cp-source {
    font-size: 11px;
    color: #999;
}

.control-point-item .cp-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

/* Hide default MapLibre navigation control */
.maplibregl-ctrl-top-right {
    display: none !important;
}

/* Control point popup styles */
.control-point-popup .maplibregl-popup-content {
    padding: 10px 12px;
    font-size: 12px;
    max-width: 280px;
}

.control-point-popup .popup-type {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

.control-point-popup .popup-row {
    margin: 3px 0;
    color: #555;
}

.control-point-popup .popup-row strong {
    color: #333;
}

/* Zoom level indicator - top right corner */
#zoom-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    min-width: 36px;
    height: 22px;
    padding: 0 6px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    font-family: monospace;
    color: #333;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* KTG1 Logo - bottom left corner */
#ktg1-logo {
    position: absolute;
    bottom: 10px;
    left: 10px;
    height: 30px;
    z-index: 1000;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s;
}

#ktg1-logo:hover {
    opacity: 1;
}

#telegram-link {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 14px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#telegram-link a {
    color: #0088cc;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

#telegram-link a:hover {
    text-decoration: underline;
}

.telegram-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Desktop styles for segment panels container */
#segmentPanelsContainer {
    top: 94px;
    bottom: 8px;
    left: 8px;
    width: 400px;
    overflow-y: auto;
    padding-bottom: 5px;
}

/* Mobile styles */
@media (max-width: 768px) {
    html {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    body {
        overflow-x: hidden;
        overflow-y: auto;
        position: fixed;
        width: 100%;
        height: 100%;
        -webkit-overflow-scrolling: touch;
    }

    /* Segments header on mobile */
    .segments-header {
        width: calc(100vw - 16px) !important;
        left: 8px !important;
    }

    /* Segment labels on mobile - positioned below route icon */
    .segment-label {
        position: absolute;
        left: 0;
        right: auto;
        top: auto;
        bottom: 3px;
        transform: translateY(100%);
        margin-top: 0;
        width: 52px;
        height: auto;
        padding: 4px 0;
        border-radius: 0 0 8px 8px;
        font-size: 11px;
        writing-mode: horizontal-tb;
        text-orientation: initial;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        z-index: 1;
        opacity: 0;
    }

    /* Show label when route panel is minimized (regardless of vehicle panel state) */
    .segment-pair.route-minimized .segment-label {
        opacity: 1;
    }

    /* No extra margin needed - container has padding-bottom */
    .segment-pair.route-minimized {
        margin-bottom: 0 !important;
    }

    /* Top action buttons on mobile */
    .top-action-buttons {
        width: calc(100vw - 8px) !important;
        left: 4px !important;
    }

    /* Segments header on mobile - below SR button with 5px gap */
    /* SR button: top 8px + height ~37px = bottom ~45px. Header at 50px for 5px gap */
    .segments-header {
        width: calc(100vw - 8px) !important;
        left: 4px !important;
        top: 50px !important;
    }

    /* Mobile: horizontal scroll container for segment pairs */
    /* Header ends at ~80px (50 + 30), container at 85px (5px spacing) */
    #segmentPanelsContainer {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        width: calc(100vw - 8px) !important;
        max-width: calc(100vw - 8px) !important;
        left: 4px !important;
        top: 85px !important;
        bottom: auto !important;
        height: auto !important;
        min-height: 110px !important;
        max-height: none !important;
        gap: 8px;
        padding: 0 !important;
        padding-left: 4px !important; /* Push content away from left edge */
        padding-bottom: 25px; /* space for label below */
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scroll-padding: 4px !important; /* Match padding-left */
    }

    /* Segment pair: minimized = compact, expanded = full width */
    .segment-pair {
        flex-shrink: 0;
        overflow: visible;
        display: flex;
        flex-direction: column;
        scroll-snap-align: center;
        gap: 0 !important;
    }

    /* When both minimized - compact width, no gap between icons */
    .segment-pair.both-minimized {
        width: auto !important;
    }

    /* Compact styling for collapsed panels in segment-pair on mobile */
    .segment-pair .vehicle-panel:not(.expanded),
    .segment-pair .route-panel:not(.expanded) {
        margin: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Compact header padding on mobile - FIXED selector for route-panel */
    .segment-pair .vehicle-panel:not(.expanded) .vehicle-panel-header,
    .segment-pair .route-panel:not(.expanded) .route-panel-header {
        padding: 4px 6px !important;
    }

    /* When any panel expanded - match width with buttons/header */
    .segment-pair:not(.both-minimized) {
        width: calc(100vw - 8px) !important;
        min-width: calc(100vw - 8px) !important;
        margin: 0 auto !important;
    }

    /* Keep collapsed panels (not expanded) inline */
    .segment-pair .vehicle-panel:not(.expanded),
    .segment-pair .route-panel:not(.expanded) {
        width: fit-content !important;
    }

    /* When in row (not minimized), limit panel width to parent */
    .segment-pair:not(.both-minimized) .vehicle-panel:not(.expanded),
    .segment-pair:not(.both-minimized) .route-panel:not(.expanded) {
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }

    /* Expanded panels take full width */
    .segment-pair .vehicle-panel.expanded,
    .segment-pair .route-panel.expanded {
        width: 100% !important;
    }

    .route-panel {
        width: 98%;
        left: 1%;
        right: 1%;
        top: 68px;
        overflow-x: hidden !important;
    }

    /* Route panel in segment pairs needs overflow visible for label */
    .segment-pair .route-panel {
        overflow: visible !important;
    }

    .vehicle-panel {
        width: 98%;
        left: 1%;
        right: 1%;
        top: 10px;
        position: absolute;
        overflow-x: hidden !important;
    }

    /* Main panels: stacked vertically with no gap, like segment-pair */
    #vehiclePanel:not(.expanded) {
        width: auto !important;
        left: 8px !important;
        top: 10px !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }

    #routePanel:not(.expanded) {
        width: auto !important;
        left: 8px !important;
        top: 58px !important;
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
    }

    /* When SR button is visible on mobile, shift main panels down (not segment-pair panels) */
    body.has-sr-button #vehiclePanel:not(.expanded) {
        top: 56px !important;
    }

    body.has-sr-button #routePanel:not(.expanded) {
        top: 104px !important;
    }

    /* Legend panel on mobile - keep icon in bottom right */
    .legend-panel {
        right: 8px;
        bottom: 8px;
    }

    .legend-content {
        width: calc(100vw - 24px);
        max-width: 400px;
    }

    /* Hide zoom indicator on mobile, show logo instead */
    #zoom-indicator {
        display: none;
    }

    /* Logo stays in bottom-left on mobile */
    #ktg1-logo {
        bottom: 10px;
        left: 10px;
    }

    /* Reset button on mobile */
    .reset-all-btn:not(.minimized) {
        width: 100% !important;
    }

    .reset-all-btn.minimized {
        width: auto !important;
        min-width: 52px;
        min-height: 48px;
    }

    /* Меньше padding на мобильном */
    .route-panel-content {
        padding: 12px;
    }

    .vehicle-icon,
    .route-icon {
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
    }

    /* Higher specificity for icons in segment-pair */
    .segment-pair .vehicle-icon,
    .segment-pair .route-icon {
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
        display: block !important;
        object-fit: contain !important;
        box-sizing: border-box !important;
    }

    /* Remove border-radius where icons stack */
    .segment-pair .vehicle-panel:not(.expanded) {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }

    .segment-pair .route-panel:not(.expanded) {
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
    }

    /* Reset button in segment container - aligned to top */
    #segmentPanelsContainer .reset-all-btn {
        flex-shrink: 0 !important;
        margin-left: 8px !important;
        scroll-snap-align: none !important;
        width: auto !important;
        height: 109px !important;
        align-self: flex-start !important;
    }

    /* Keep button text visible, not minimized icon */
    #segmentPanelsContainer .reset-all-btn .reset-text {
        display: inline !important;
    }

    #segmentPanelsContainer .reset-all-btn .reset-icon {
        display: none !important;
    }

    /* Fix autocomplete overflow on mobile */
    .autocomplete-dropdown {
        width: 100%;
        max-width: 100%;
    }

    /* Ensure inputs don't overflow */
    .route-panel input,
    .vehicle-panel input {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Prevent any child overflow */
    .route-panel-header,
    .route-panel-content,
    .vehicle-panel-header,
    .vehicle-panel-content {
        overflow-x: hidden;
        max-width: 100%;
    }

    .route-coords-badge {
        overflow: hidden;
        max-width: calc(100% - 50px);
    }

    /* Coordinate badge tooltips - show below on mobile */
    .coord-badge::after {
        bottom: auto;
        top: 100%;
        margin-bottom: 0;
        margin-top: 4px;
        z-index: 9999;
        max-width: 200px;
        white-space: normal;
        word-break: break-all;
    }

}

/* ============ SESSION SHARING UI ============ */

/* Share modal overlay */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.share-modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.share-modal h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    color: #1a202c;
}

.share-modal p {
    margin: 0 0 16px 0;
    color: #4a5568;
    font-size: 14px;
    line-height: 1.5;
}

.share-url-box {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.share-url-box input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 13px;
    color: #2d3748;
    background: #f7fafc;
    transition: border-color 0.2s;
}

.share-url-box input:focus {
    outline: none;
    border-color: #0933AB;
    background: white;
}

.share-url-box .copy-btn {
    padding: 10px 20px;
    background: #0933AB;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
    white-space: nowrap;
}

.share-url-box .copy-btn:hover {
    background: #072a8a;
}

.share-url-box .copy-btn:active {
    transform: scale(0.98);
}

.share-note {
    font-size: 12px !important;
    color: #718096 !important;
    margin: 12px 0 !important;
    font-style: italic;
}

.close-btn {
    width: 100%;
    padding: 10px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10001;
    max-width: 350px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
}

.toast-error {
    background: linear-gradient(135deg, #f44336 0%, #ef5350 100%);
}

.toast-info {
    background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%);
}

.toast-warning {
    background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%);
}

/* ============ INFO MODALS (Updates / About) ============ */

.info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
}

.info-modal {
    background: white;
    border-radius: 12px;
    width: 500px;
    max-width: 92vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.3s ease-out;
}

.info-modal.info-modal-wide {
    width: 600px;
}

.info-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.info-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #333;
}

.info-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.info-close-btn:hover {
    color: #333;
}

.info-modal-body {
    padding: 16px 20px 20px;
    overflow-y: auto;
    flex: 1;
}

.info-modal-body section {
    margin-bottom: 16px;
}

.info-modal-body section:last-child {
    margin-bottom: 0;
}

.info-modal-body h4 {
    font-size: 15px;
    font-weight: 600;
    color: #1a202c;
    margin: 0 0 8px 0;
}

.info-modal-body p {
    font-size: 14px;
    color: #4a5568;
    line-height: 1.6;
    margin: 0 0 8px 0;
}

.info-modal-body p:last-child {
    margin-bottom: 0;
}

.info-modal-body ul,
.info-modal-body ol {
    font-size: 14px;
    color: #4a5568;
    line-height: 1.6;
    margin: 0 0 8px 0;
    padding-left: 20px;
}

.info-modal-body li {
    margin-bottom: 4px;
}

.info-modal-body a {
    color: #1976d2;
    text-decoration: none;
}

.info-modal-body a:hover {
    text-decoration: underline;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .share-modal-content {
        max-width: 90%;
        padding: 20px;
    }

    .share-url-box {
        flex-direction: column;
    }

    .share-url-box .copy-btn {
        width: 100%;
    }

    .toast {
        bottom: 20px;
        right: 20px;
        left: 20px;
        max-width: none;
    }

    .feedback-modal {
        width: 100%;
        max-width: 92vw;
        margin: 0 16px;
    }

    .feedback-actions {
        flex-direction: column;
    }

    .feedback-send-btn {
        width: 100%;
    }

    .info-modal,
    .info-modal.info-modal-wide {
        width: 100%;
        max-width: 92vw;
        margin: 0 16px;
        max-height: 80vh;
    }
}

/* ============================================================
   SR Import Button & Modal
   ============================================================ */

/* Import button - inside route panel */
/* Add route button */
.add-route-btn {
    display: none;
    width: 100%;
    padding: 10px 16px;
    margin-top: 6px;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: background 0.2s;
}
.add-route-btn:hover {
    background: #c8e6c9;
}
.add-route-btn .add-route-icon {
    margin-left: 6px;
    font-weight: bold;
}

.import-sr-btn {
    display: none;
    background: #0933AB;
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    padding: 10px 16px;
    border-radius: 6px;
    margin-top: 10px;
    text-align: center;
}

.import-sr-btn:hover {
    background: #072a8a;
}

.import-sr-btn.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Import button icon - hidden by default */
.import-sr-btn .import-icon {
    display: none;
    font-size: 20px;
    font-weight: bold;
}

/* Narrowed state for buttons when all panels minimized */
.import-sr-btn.narrowed {
    width: 90px !important;
    padding: 10px 8px;
}

.import-sr-btn.narrowed .import-text {
    display: none !important;
}

.import-sr-btn.narrowed .import-icon {
    display: block !important;
}

.reset-all-btn.narrowed {
    width: 90px !important;
    padding: 8px;
}

.reset-all-btn.narrowed .reset-text {
    display: none !important;
}

.reset-all-btn.narrowed .reset-icon {
    display: inline !important;
}

/* ============================================================
   Passability Check Button & Legend
   ============================================================ */

.passability-check-btn {
    display: none;
    background: #6B46C1;
    color: white;
    border: none;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 8px;
    text-align: center;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.passability-check-btn:hover {
    background: #553C9A;
}

.passability-check-btn.visible {
    display: flex;
}

.passability-check-btn.loading {
    background: #805AD5;
    cursor: wait;
}

.passability-check-btn .passability-icon {
    font-size: 16px;
}

/* Passability legend (similar to SR edge legend) */
.passability-legend {
    position: absolute;
    bottom: 80px;
    right: 10px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 10px 14px;
    z-index: 100;
    font-size: 13px;
}

.passability-legend-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.passability-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.passability-legend-color {
    width: 20px;
    height: 12px;
    border-radius: 2px;
}

.passability-legend-color.measures {
    background: #DD0C3E;
}

.passability-legend-color.podd {
    background: #F3BB10;
}

.passability-legend-color.both {
    background: repeating-linear-gradient(
        90deg,
        #DD0C3E 0px, #DD0C3E 4px,
        #F3BB10 4px, #F3BB10 8px
    );
}

/* Passability result message (success/info) */
.passability-result {
    position: absolute;
    bottom: 80px;
    right: 10px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 12px 18px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 100;
    font-size: 14px;
    font-weight: 500;
    max-width: 320px;
    animation: fadeInOut 5s ease-in-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(10px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* Passability popup (for known roads layer) */
.passability-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.passability-popup-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e0e0e0;
}

.passability-popup-title small {
    display: block;
    font-weight: 400;
    font-size: 11px;
    color: #777;
    margin-top: 4px;
}

.passability-popup-limits {
    font-size: 13px;
    line-height: 1.5;
    color: #555;
}

.passability-popup-date {
    margin-top: 8px;
    font-size: 11px;
    color: #999;
}

.passability-popup-overlay {
    margin-top: 8px;
    font-size: 10px;
    color: #888;
    word-break: break-all;
    padding-top: 6px;
    border-top: 1px dashed #ddd;
}

/* Passability loader overlay */
.passability-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.passability-loader-content {
    background: white;
    padding: 30px 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.passability-loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #6B46C1;
    border-radius: 50%;
    animation: passability-spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes passability-spin {
    to { transform: rotate(360deg); }
}

.passability-loader-text {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.passability-loader-progress {
    font-size: 14px;
    color: #666;
    margin-bottom: 4px;
}

.passability-loader-time {
    font-size: 13px;
    color: #888;
}

/* Import modal overlay */
.import-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.import-modal {
    background: white;
    border-radius: 12px;
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
}

.import-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.import-modal-header h3 {
    margin: 0;
    font-size: 17px;
    color: #1a1a2e;
}

.import-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
    line-height: 1;
}

.import-modal-close:hover {
    color: #333;
}

.import-modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Step 1: URL input */
.import-label {
    display: block;
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}

.import-url-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.import-url-input:focus {
    outline: none;
    border-color: #0933AB;
    box-shadow: 0 0 0 2px rgba(9,51,171,0.15);
}

.import-fetch-btn {
    width: 100%;
    padding: 12px;
    background: #0933AB;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.import-fetch-btn:hover:not(:disabled) {
    background: #072a8a;
}

.import-fetch-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.import-error {
    margin-top: 10px;
    padding: 10px;
    background: #ffebee;
    color: #c62828;
    border-radius: 6px;
    font-size: 13px;
}

/* Spinner for buttons */
.import-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: import-spin 0.7s linear infinite;
}

@keyframes import-spin {
    to { transform: rotate(360deg); }
}

/* Step 2: Route table */
.import-vehicle-badge {
    padding: 10px 14px;
    background: #e3f2fd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    text-align: center;
}

.import-hint {
    font-size: 13px;
    color: #666;
    margin: 0 0 8px 0;
}

.import-table-wrap {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 12px;
}

.import-route-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.import-route-table thead th {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #444;
    border-bottom: 1px solid #e0e0e0;
}

.import-route-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.import-route-table tbody tr:hover {
    background: #f0f7ff;
}

.import-route-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
}

.import-route-table tbody td:first-child {
    width: 30px;
    text-align: center;
}

.import-route-cb {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #0933AB;
}

.import-build-btn {
    width: 100%;
    padding: 12px;
    background: #0933AB;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.import-build-btn:hover:not(:disabled) {
    background: #072a8a;
}

.import-build-btn:disabled {
    background: #9e9e9e;
    cursor: not-allowed;
}

/* Import route legend (shown when multiple routes) */
.import-route-legend {
    position: absolute;
    top: 68px;
    right: 8px;
    background: white;
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 4;
    font-size: 13px;
}

.import-legend-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
}

.import-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.import-legend-color {
    width: 20px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Mobile responsive for import */
@media (max-width: 768px) {
    .import-sr-btn {
        width: 100%;
    }

    .import-modal {
        width: 100%;
        max-width: 100%;
        border-radius: 12px 12px 0 0;
        max-height: 80vh;
    }

    .import-route-legend {
        top: auto;
        bottom: 8px;
        right: 8px;
    }
}

/* Imported via points info badge */
.imported-via-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin: 0 12px 8px;
    background: #FFF3E0;
    border: 1px solid #FFB74D;
    border-radius: 6px;
    font-size: 12px;
    color: #E65100;
    line-height: 1.3;
}
.imported-via-icon {
    flex-shrink: 0;
}

/* Vehicle warning bubble (ПОДД / escort vehicles) */
.vehicle-warning-bubble {
    position: fixed;
    background: #333;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 10000;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    line-height: 1.4;
    animation: bubbleFadeIn 0.2s ease-out;
}

@keyframes bubbleFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Arrow pointing up (toward the input field) — left set dynamically via JS */
.vehicle-warning-bubble::before {
    content: '';
    position: absolute;
    top: -8px;
    left: var(--arrow-left, 20px);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #333;
}

/* Dismiss button */
.vehicle-warning-bubble .dismiss-btn {
    display: inline-block;
    margin-top: 8px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}

.vehicle-warning-bubble .dismiss-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* ========================================
   MOBILE TUTORIAL - First Visit Onboarding
   ======================================== */

/* Tutorial overlay */
.mobile-tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 25vh;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mobile-tutorial-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Tutorial message box */
.tutorial-message {
    background: white;
    border-radius: 12px;
    padding: 20px 24px;
    max-width: 320px;
    margin: 0 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    text-align: center;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.4s ease;
}

.mobile-tutorial-overlay.visible .tutorial-message {
    transform: translateY(0);
    opacity: 1;
}

.tutorial-message h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.tutorial-message p {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 16px;
}

.tutorial-skip-btn {
    background: #f0f0f0;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: background 0.2s;
}

.tutorial-skip-btn:hover {
    background: #e0e0e0;
}

/* Pulsing tap indicator */
.tutorial-tap-indicator {
    position: fixed;
    width: 50px;
    height: 50px;
    pointer-events: none;
    z-index: 20001;
    transform: translate(-50%, -50%);
    display: none;
}

.tutorial-tap-indicator.active {
    display: block;
}

.tutorial-tap-indicator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: rgba(220, 53, 69, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: tapPulseCore 1s ease-in-out infinite;
}

.tutorial-tap-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: rgba(220, 53, 69, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: tapPulseRing 1s ease-in-out infinite;
}

@keyframes tapPulseCore {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
}

@keyframes tapPulseRing {
    0%, 100% {
        transform: translate(-50%, -50%) scale(0.6);
        opacity: 0.5;
    }
    50% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.2;
    }
}

/* Highlight effect for targeted element */
.tutorial-highlight {
    position: relative;
    z-index: 20002 !important;
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.4) !important;
    border-radius: 50%;
}

/* ============================================================
   SR EDGE SEGMENT POPUP STYLES
   ============================================================ */

.sr-edge-popup {
    padding: 4px 0;
    font-size: 13px;
    line-height: 1.5;
}

.sr-edge-popup-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e0e0e0;
    color: #1a202c;
}

.sr-edge-popup-row {
    margin: 4px 0;
    color: #4a5568;
}

.sr-edge-popup-row b {
    color: #2d3748;
    font-weight: 500;
}

/* Legend for SR edge segments */
.sr-edge-legend {
    position: absolute;
    bottom: 120px;
    right: 16px;
    background: white;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 12px;
    z-index: 200;
    max-width: 200px;
}

.sr-edge-legend-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #1a202c;
}

.sr-edge-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

.sr-edge-legend-color {
    width: 24px;
    height: 6px;
    border-radius: 2px;
    flex-shrink: 0;
}

.sr-edge-legend-color.measures { background: #DD0C3E; }
.sr-edge-legend-color.podd { background: #F3BB10; }
.sr-edge-legend-color.heavy { background: #FFFFFF; border: 1px solid #ccc; }
.sr-edge-legend-color.both {
    background: repeating-linear-gradient(
        90deg,
        #DD0C3E 0px,
        #DD0C3E 4px,
        #F3BB10 4px,
        #F3BB10 8px
    );
}

/* Multi-route import panels - now using existing subRoutes panel system */
/* Styles removed - using standard segment panel UI */

/* Special segments (measures/ПОДД) badges */
.restriction-type-badge.badge-measures {
    background: #ffebee;
    color: #c62828;
    font-weight: 700;
}

.restriction-type-badge.badge-podd {
    background: #fff3e0;
    color: #e65100;
    font-weight: 700;
}

.restriction-type-badge.badge-both {
    background: #fff8e1;
    color: #bf360c;
    font-weight: 700;
}

.restriction-item.special-segment {
    border-left-color: #c2185b;
    background: #fef7f9;
}
