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

        :root {
            --primary: #007AFF;
            --secondary: #5856D6;
            --success: #34C759;
            --danger: #FF3B30;
            --warning: #FF9500;
            --background: #F2F2F7;
            --surface: #FFFFFF;
            --text-primary: #000000;
            --text-secondary: #6C6C70;
            --border: #E5E5EA;
            --shadow: rgba(0, 0, 0, 0.1);
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            background: var(--background);
            color: var(--text-primary);
            overflow: hidden;
            height: 100vh;
        }

        /* Floating Toggle Button (for when sidebar is collapsed) */
        .floating-toggle {
            position: absolute;
            top: 16px;
            left: 16px;
            width: 44px;
            height: 44px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--border);
            border-radius: 12px;
            cursor: pointer;
            display: none;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            z-index: 200;
            color: var(--text-secondary);
            box-shadow: 0 2px 8px var(--shadow);
        }

        .floating-toggle:hover {
            background: var(--border);
            color: var(--text-primary);
            transform: scale(1.05);
            box-shadow: 0 4px 16px var(--shadow);
        }

        .floating-toggle.show {
            display: flex;
        }

        /* Map Container */
        #map {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 1;
        }

        /* Sidebar */
        .sidebar {
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            width: 380px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-right: 1px solid var(--border);
            z-index: 100;
            display: flex;
            flex-direction: column;
            transform: translateX(0);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .sidebar.collapsed {
            transform: translateX(-100%);
        }

        /* Search Container */
        .search-container {
            padding: 16px 12px;
            border-bottom: 1px solid var(--border);
        }

        .search-box {
            position: relative;
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
        }

        .toggle-sidebar {
            background: var(--background);
            border: 1px solid var(--border);
            border-radius: 12px;
            width: 44px;
            height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;
            color: var(--text-secondary);
            flex-shrink: 0;
        }

        .toggle-sidebar:hover {
            background: var(--border);
            color: var(--text-primary);
        }

        .search-input-wrapper {
            position: relative;
            flex: 1;
        }

        .search-box input {
            width: 100%;
            padding: 12px 16px 12px 44px;
            border: 1px solid var(--border);
            border-radius: 12px;
            font-size: 16px;
            background: var(--surface);
            transition: all 0.2s ease;
        }

        .search-box input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
        }

        .search-box i.fa-search {
            position: absolute;
            left: 16px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-secondary);
            pointer-events: none;
        }

        .search-box .waypoint-action {
            flex-shrink: 0;
        }

        /* Waypoints List */
        .waypoints-container {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
        }

        .waypoint-item {
            background: var(--surface);
            border-radius: 16px;
            padding: 16px;
            margin-bottom: 12px;
            border: 1px solid var(--border);
            transition: all 0.2s ease;
            cursor: move;
            position: relative;
        }

        .waypoint-item:hover {
            box-shadow: 0 4px 12px var(--shadow);
            transform: translateY(-2px);
        }

        .waypoint-item.dragging {
            opacity: 0.5;
            transform: scale(0.95);
        }

        .waypoint-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 8px;
        }

        .waypoint-number {
            width: 32px;
            height: 32px;
            background: var(--primary);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 14px;
        }

        .waypoint-name {
            flex: 1;
            font-weight: 600;
            font-size: 16px;
        }

        .waypoint-actions {
            display: flex;
            gap: 8px;
        }

        .waypoint-action {
            width: 32px;
            height: 32px;
            border: none;
            background: var(--background);
            border-radius: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            color: var(--text-secondary);
        }

        .waypoint-action:hover {
            background: var(--border);
            color: var(--text-primary);
        }

        .waypoint-action.delete:hover {
            background: var(--danger);
            color: white;
        }

        .waypoint-details {
            margin-left: 44px;
            font-size: 14px;
            color: var(--text-secondary);
        }

        .waypoint-route-info {
            margin-left: 44px;
            margin-top: 8px;
            font-size: 13px;
            color: var(--primary);
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .waypoint-route-info i {
            margin-right: 4px;
        }

        .waypoint-route-info.fallback {
            color: var(--warning);
        }

        .waypoint-route-info .route-type {
            font-size: 11px;
            background: var(--background);
            padding: 2px 6px;
            border-radius: 6px;
            margin-left: auto;
        }

        .waypoint-route-info.fallback .route-type {
            background: rgba(255, 149, 0, 0.1);
            color: var(--warning);
        }

        /* Add Button */
        .add-waypoint-btn {
            margin: 16px;
            padding: 16px;
            background: var(--primary);
            color: white;
            border: none;
            border-radius: 16px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .add-waypoint-btn:hover {
            background: #0066CC;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
        }

        /* Sidebar Stats */
        .sidebar-stats {
            padding: 16px 24px;
            border-top: 1px solid var(--border);
            background: rgba(0, 122, 255, 0.02);
            margin-top: auto; /* Push to bottom of sidebar */
        }

        .sidebar-stats .stats-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--text-primary);
        }

        .sidebar-stats .stat-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 0;
            border-bottom: 1px solid var(--border);
        }

        .sidebar-stats .stat-item:last-child {
            border-bottom: none;
        }

        .sidebar-stats .stat-label {
            color: var(--text-secondary);
            font-size: 14px;
        }

        .sidebar-stats .stat-value {
            font-weight: 600;
            font-size: 14px;
            color: var(--text-primary);
        }

        /* Empty State */
        .empty-state {
            text-align: center;
            padding: 48px 24px;
            color: var(--text-secondary);
        }

        .empty-state i {
            font-size: 64px;
            margin-bottom: 16px;
            opacity: 0.3;
        }

        .empty-state p {
            font-size: 16px;
            margin-bottom: 24px;
        }

        /* Loading State */
        .loading {
            display: inline-block;
            width: 16px;
            height: 16px;
            border: 2px solid var(--border);
            border-radius: 50%;
            border-top-color: var(--primary);
            animation: spin 1s ease-in-out infinite;
        }

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

        /* Animations */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .waypoint-item {
            animation: fadeIn 0.3s ease;
        }

        /* Responsive - prioritize map on small screens */
        @media (max-width: 768px) {
            .sidebar {
                width: 100vw; /* Full viewport width when open */
                transform: translateX(-100%); /* Start collapsed by default */
            }
            
            .sidebar:not(.collapsed) {
                transform: translateX(0); /* Show when explicitly opened */
            }
            
            /* Ensure floating toggle is visible on mobile */
            .floating-toggle {
                display: flex;
            }
        }

        /* Custom Leaflet Styles */
        .leaflet-marker-icon {
            transition: all 0.2s ease;
        }

        .leaflet-marker-icon:hover {
            transform: scale(1.1);
        }

        /* Route styling for mixed routes */
        .leaflet-interactive.mixed-route {
            stroke-dasharray: 8, 4;
        }