body {
    margin: 0;
    font-family: Outfit, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    height: 100vh;
    background: #E7ECF4;
}

:root {
    --brand-blue: #266CF1;
    --brand-blue-dark: #1e50c7;
    --ink: #112140;
    --surface: #ffffff;
    --surface-soft: rgba(231, 236, 244, 0.6);
    --line: rgba(17, 33, 64, 0.12);
    --success: #0f9d58;
    --danger: #dc2626;
}

html,
body {
    height: 100%;
}

h3,
h4,
p {
    margin-top: 0;
}

#topbar {
    width: 360px;
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 56px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    z-index: 30000;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.85);
}

#topbar h3 {
    font-size: 16px;
    margin: 0;
}

#topbar button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: #266CF1;
    color: #fff;
    cursor: pointer;
    margin: 0;
    transition: all 0.28s ease;
}

#topbar button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(38, 108, 241, 0.32);
}

#popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);

    background: rgba(38, 108, 241, 0.94);
    color: #fff;
    border: rgba(255, 255, 255, 0.25) solid 1px;

    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;

    display: none;
    z-index: 99999;

    box-shadow: 0 10px 25px rgba(38, 108, 241, 0.2);

    width: auto;
    max-width: 333px;
    text-align: center;
}

#popup.popup-success {
    background: linear-gradient(135deg, #15b66c, #0e8d52);
}

#popup.popup-error {
    background: linear-gradient(135deg, #f05252, #dc2626);
}

#popup.popup-info {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.leaflet-left {
    right: 20px;
    left: unset !important;
}

#sidebar {
    position: fixed;
    top: 76px;
    left: 10px;
    width: 360px;
    max-height: calc(100vh - 90px);
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    overflow-y: auto;
    z-index: 25000;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#sidebar.collapsed {
    transform: translateX(-110%);
    opacity: 0;
}

@media (max-width: 768px) {
    #sidebar {
        width: 85%;
        max-width: 339px;
        left: 10px;
        right: 10px;
    }

    #topbar {
        width: 85%;
        max-width: 339px;
        left: 10px;
        right: 10px;
    }

    #popup {
        width: 80% !important;
        max-width: 339px;
    }
}

.sidebarToggle {
    position: absolute;
    top: 18px;
    left: 18px;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    z-index: 2000;
}

.sidebarToggleclose {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    margin-right: 12px;
    border: none;
    cursor: pointer;
}

#sidebar.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
    box-shadow: none;
}

#summaryPanel {
    background: linear-gradient(135deg, rgba(207, 222, 253, 0.5), rgba(231, 236, 244, 0.8));
    border-left: 4px solid #266CF1;
    margin-top: 12px;
}

#summary {
    font-size: 13px;
    line-height: 1.5;
    color: #112140;
    font-weight: 500;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.summary-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    display: grid;
    gap: 2px;
}

.summary-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: rgba(17, 33, 64, 0.65);
}

.summary-value {
    font-size: 17px;
    font-weight: 700;
    color: #112140;
}

.summary-sub {
    font-size: 11px;
    color: rgba(17, 33, 64, 0.65);
}

.summary-meta {
    margin-top: 8px;
    font-size: 12px;
    color: rgba(17, 33, 64, 0.74);
}

#map {
    flex: 1;
}

#map {
    height: 100vh;
    width: 100%;
    min-height: 300px;
}

.card {
    display: grid;
    background: rgba(231, 236, 244, 0.6);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1px solid rgba(17, 33, 64, 0.08);
}

.card.form-submit {
    margin-top: auto;
}

.bulk-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.bulk-actions button {
    margin-top: 0;
}

.bulk-panel {
    display: none;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 10px 24px rgba(17, 33, 64, 0.08);
}

.bulk-panel.open {
    display: grid;
    gap: 8px;
}

.bulk-label {
    margin-top: 0;
    font-size: 12px;
}

#bulkStopsInput {
    width: 100%;
    min-height: 92px;
    resize: vertical;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 10px 12px;
    font-family: inherit;
    line-height: 1.45;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
}

#bulkStopsInput:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(38, 108, 241, 0.1);
}

label {
    display: block;
    font-size: 14px;
    margin-top: 16px;
    margin-bottom: 4px;
    color: #112140;
    font-weight: 600;
}

input,
select {
    width: auto;
    max-width: 100%;
    padding: 10px;
    margin-top: 6px;
    border-radius: 8px;
    border: 1px solid rgba(17, 33, 64, 0.12);
    font-family: Outfit, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: rgba(255, 255, 255, 0.8);
    color: #112140;
}

input:focus,
select:focus {
    outline: none;
    border-color: #266CF1;
    box-shadow: 0 0 0 3px rgba(38, 108, 241, 0.1);
}

button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 10px;
    margin-top: 8px;
    background: #266CF1;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    font-family: Outfit, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: all 0.28s ease;
}

button:hover {
    background: #1e50c7;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(38, 108, 241, 0.3);
}

.small-btn {
    background: rgba(17, 33, 64, 0.08);
    color: #112140;
    font-size: 12px;
    transition: all 0.28s ease;
}

.small-btn:hover {
    background: rgba(17, 33, 64, 0.16);
}

#stops {
    display: grid;
    gap: 6px;
}

.stop {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 34px;
    align-items: start;
    gap: 6px;
    margin-top: 0;
}

.stop input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.stopsuggest {
    position: relative;
}

.drag-handle {
    margin-top: 6px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 33, 64, 0.08);
    color: #112140;
    cursor: grab;
    user-select: none;
    font-weight: 700;
    letter-spacing: 1px;
}

.stop.dragging {
    opacity: 0.55;
}

.stop.drop-target {
    outline: 2px dashed rgba(38, 108, 241, 0.45);
    outline-offset: 2px;
    border-radius: 8px;
}

.stop .suggest-list {
    left: 34px;
    width: calc(100% - 74px);
}

.stop-readonly {
    grid-template-columns: minmax(0, 1fr);
}

.stop-readonly .suggest-list,
.stop-readonly .drag-handle,
.stop-readonly .remove-btn {
    display: none;
}

.remove-btn {
    margin-top: 6px;
    height: 40px;
    width: 34px;
    min-width: 34px;
    position: relative;
    z-index: 3;
    cursor: pointer;
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 0;
    border-radius: 8px;
    max-width: none;
    font-weight: 600;
    transition: all 0.28s ease;
}

.remove-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

.row {
    display: flex;
    gap: 8px;
}

.row button {
    flex: 1;
}

#navigatePanel,
#summaryPanel,
#sharePanel {
    display: none;
}

#explorePanel {
    display: grid;
    justify-items: center;
    padding: 24px;
    background: linear-gradient(135deg, rgba(207, 222, 253, 0.6) 0%, rgba(231, 236, 244, 0.8) 100%);
    box-shadow: 0 12px 24px rgba(17, 33, 64, 0.1);
    border-radius: 12px;
}

#explorePanel a.btnExplore {
    width: 100%;
    padding: 16px 4px;
    border: none;
    border-radius: 10px;
    margin-top: 8px;
    background: linear-gradient(135deg, #266CF1 0%, #1e50c7 100%);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.28s ease;
    font-family: Outfit, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#explorePanel a.btnExplore:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(38, 108, 241, 0.3);
}

.summary {
    font-size: 14px;
    margin-top: 8px;
}

#sharePanel .btnLinks {
    display: flex;
    gap: 8px;
}

#sharePanel .btnLinks button {
    background: transparent;
    border: #266CF1 solid 2px;
    color: #266CF1;
    transition: all 0.28s ease;
}

#sharePanel .btnLinks button:hover {
    background: rgba(38, 108, 241, 0.08);
}

#qr {
    display: none;
    text-align: center;
    margin-top: 10px;
    padding: 10px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.suggest {
    display: grid;
    position: relative;
}

.suggest-list {
    position: absolute;
    top: 45px;
    z-index: 999;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(17, 33, 64, 0.1);
    width: 100%;
    max-height: 220px;
    overflow: auto;
    border-radius: 12px;
    box-shadow: 0 16px 35px rgba(17, 33, 64, 0.16);
    backdrop-filter: blur(8px);
}

.suggest-item {
    padding: 10px 12px;
    cursor: pointer;
    color: #112140;
    border-bottom: 1px solid rgba(17, 33, 64, 0.06);
}

.suggest-item:last-child {
    border-bottom: 0;
}

.suggest-item:hover {
    background: rgba(38, 108, 241, 0.08);
}

.suggest-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #0e1f41;
}

.suggest-item-subtitle {
    margin-top: 2px;
    font-size: 11px;
    color: rgba(17, 33, 64, 0.68);
}

.suggest-item-empty {
    cursor: default;
    color: rgba(17, 33, 64, 0.6);
}

.suggest-item-empty:hover {
    background: transparent;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(7, 17, 36, 0.45);
    backdrop-filter: blur(4px);
    z-index: 120000;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    width: min(430px, 100%);
    background: #fff;
    border: 1px solid rgba(17, 33, 64, 0.1);
    border-radius: 14px;
    box-shadow: 0 24px 50px rgba(17, 33, 64, 0.25);
    padding: 18px;
}

.modal-card h4 {
    margin: 0;
    font-size: 18px;
    color: #112140;
}

.modal-card p {
    margin: 8px 0 0;
    font-size: 14px;
    color: rgba(17, 33, 64, 0.8);
}

.modal-actions {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 560px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        grid-template-columns: 1fr;
    }
}

.stop-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

.stop-marker {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #ef4444;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid #fff;
    box-shadow: 0 4px 10px rgba(17, 33, 64, 0.25);
}

.stop-marker.preview {
    background: #266CF1;
}

.car-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

.car-marker {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    /* color: #ffffff; */
    /* background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%); */
    border-radius: 14px;
    /* border: 2px solid rgba(255, 255, 255, 0.92); */
    filter: drop-shadow(0 8px 12px rgba(15, 23, 42, 0.26));
    overflow: hidden;
    box-sizing: border-box;
    transform: rotate(var(--car-rotation, 0deg));
    transform-origin: center;
    transition: transform 0.08s linear;
}

.car-icon,
.car-marker img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transform: scale(1.15);
    transform-origin: center;
    pointer-events: none;
}

.car-marker svg {
    width: 44px;
    height: 44px;
    display: block;
}

.marker-bounce {
    animation: markerBounce 0.65s cubic-bezier(0.18, 0.9, 0.22, 1.1);
    transform-origin: center bottom;
}

@keyframes markerBounce {
    0% {
        transform: translateY(-14px) scale(0.7);
        opacity: 0.2;
    }

    60% {
        transform: translateY(0) scale(1.08);
        opacity: 1;
    }

    80% {
        transform: translateY(-4px) scale(0.98);
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

#map {
    height: 100vh;
    width: 100%;
}

#globalLoader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(4px);
}

.loader {
    width: 50px;
    aspect-ratio: 1;
    display: grid;
}

.loader:before,
.loader:after {
    content: "";
    grid-area: 1/1;
    margin: 0 0 15px 15px;
    --c: #0000 calc(100%/3), #046D8B 0 calc(2*100%/3), #0000 0;
    --c1: linear-gradient(90deg, var(--c));
    --c2: linear-gradient(0deg, var(--c));
    background: var(--c1), var(--c2), var(--c1), var(--c2);
    background-size: 300% 4px, 4px 300%;
    background-repeat: no-repeat;
    animation: l12 1s infinite linear;
}

.loader:after {
    margin: 15px 15px 0 0;
    transform: scale(-1, -1);
}

@keyframes l12 {
    0% {
        background-position: 50% 0, 100% 100%, 0 100%, 0 0
    }

    25% {
        background-position: 0 0, 100% 50%, 0 100%, 0 0
    }

    50% {
        background-position: 0 0, 100% 0, 50% 100%, 0 0
    }

    75% {
        background-position: 0 0, 100% 0, 100% 100%, 0 50%
    }

    75.01% {
        background-position: 100% 0, 100% 0, 100% 100%, 0 50%
    }

    100% {
        background-position: 50% 0, 100% 0, 100% 100%, 0 100%
    }
}