* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Навигация */
nav { background: #2c3e50; color: white; padding: 10px 15px; display: flex; align-items: center; gap: 15px; flex-wrap: wrap; z-index: 1001; }
.nav-brand { font-weight: bold; font-size: 18px; margin-right: auto; }
.nav-links a { color: #ecf0f1; text-decoration: none; padding: 8px 12px; border-radius: 4px; }
.nav-links a:hover { background: #34495e; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.nav-user button { background: #e74c3c; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; }

/* Сообщения об ошибках */
.flash-message { padding: 10px 15px; border-radius: 4px; margin: 10px 15px; font-size: 14px; }
.flash-message.error { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.global-flash { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 2000; width: 90%; max-width: 400px; }

/* Контент */
#content { flex: 1; display: flex; position: relative; overflow: hidden; }
#map { flex: 1; height: 100%; z-index: 1; }

/* Боковая панель */
#sidebar, #search-panel { 
    width: 350px; 
    background: #f8f9fa; 
    border-right: 1px solid #dee2e6; 
    display: flex; 
    flex-direction: column; 
    z-index: 1000; 
    transition: transform 0.3s ease;
    max-height: 100vh;
}

#sidebar h3, #search-panel h3 { 
    padding: 15px; 
    border-bottom: 1px solid #dee2e6; 
    margin: 0; 
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Сворачиваемые группы */
details { 
    border: none;
}

details summary { 
    list-style: none;
    position: relative;
}

details summary::-webkit-details-marker { 
    display: none;
}

details summary::after {
    content: '▼';
    position: absolute;
    right: 15px;
    transition: transform 0.2s;
}

details[open] summary::after {
    transform: rotate(0deg);
}

details:not([open]) summary::after {
    transform: rotate(-90deg);
}

/* Скроллируемая область фильтров */
.filter-group { 
    flex: 1; 
    overflow-y: auto; 
    padding: 10px 15px;
    max-height: 300px;
}

.filter-group label { 
    display: flex; 
    align-items: flex-start; 
    gap: 8px; 
    padding: 5px 0; 
    font-size: 13px; 
    cursor: pointer; 
    line-height: 1.3;
}

.filter-group input[type="checkbox"] { 
    width: 16px; 
    height: 16px; 
    margin-top: 2px;
    flex-shrink: 0;
}

/* Ограничение текста в 2 строки */
.filter-group label {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.6em;
}

.filter-group small { 
    color: #6c757d; 
    font-size: 11px; 
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Кастомный скроллбар */
.filter-group::-webkit-scrollbar { width: 8px; }
.filter-group::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.filter-group::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
.filter-group::-webkit-scrollbar-thumb:hover { background: #555; }

/* Кнопки */
.apply-btn, #search-panel button, .login-box button { 
    width: 100%; 
    padding: 10px; 
    margin: 5px 0; 
    border: none; 
    border-radius: 6px; 
    font-size: 14px; 
    cursor: pointer; 
    font-weight: 600;
    background: #3498db; 
    color: white; 
}
.apply-btn:hover, #search-panel button:hover, .login-box button:hover { background: #2980b9; }

#search-panel input, .login-box input { 
    width: 100%; 
    padding: 8px; 
    border: 1px solid #ced4da; 
    border-radius: 4px; 
    font-size: 14px; 
}

/* Карта: детали и ховер */
#hover-info { 
    position: absolute; 
    top: 10px; 
    right: 10px; 
    background: rgba(255,255,255,0.95); 
    padding: 10px; 
    border-radius: 6px; 
    z-index: 1000; 
    pointer-events: none; 
    font-size: 13px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.15); 
    max-width: 250px; 
}

#ship-details { 
    position: absolute; 
    top: 10px; 
    left: 370px; 
    background: white; 
    padding: 15px; 
    border-radius: 8px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.2); 
    z-index: 1000; 
    max-width: 350px; 
    max-height: 80vh; 
    overflow-y: auto; 
}

#ship-details button.close-btn { 
    position: absolute; 
    top: 8px; 
    right: 12px; 
    background: none; 
    border: none; 
    font-size: 20px; 
    cursor: pointer; 
    color: #666; 
}

.hidden { display: none !important; }

/* Результаты поиска */
#search-results { 
    position: absolute; 
    bottom: 10px; 
    right: 10px; 
    background: white; 
    padding: 10px; 
    max-height: 40vh; 
    overflow-y: auto; 
    z-index: 1000; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.15); 
    border-radius: 8px; 
    min-width: 250px; 
}

#search-results div { 
    padding: 8px; 
    border-bottom: 1px solid #eee; 
    cursor: pointer; 
    font-size: 14px; 
}

#search-results div:hover { background: #f1f3f5; }

/* Страница входа */
.login-body { display: flex; justify-content: center; align-items: center; height: 100vh; background: #e9ecef; }
.login-box { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); display: flex; flex-direction: column; gap: 15px; width: 90%; max-width: 360px; }
.login-box h2 { text-align: center; color: #2c3e50; margin-bottom: 10px; }

/* Точки на карте для поиска */
.ship-dot, .target-marker, .route-start, .route-end { background: transparent !important; border: none !important; }

/* === МОБИЛЬНАЯ АДАПТАЦИЯ === */
@media (max-width: 768px) {
    nav { padding: 8px 10px; }
    .nav-brand { font-size: 16px; }
    .nav-links a { padding: 6px 8px; font-size: 14px; }
    .nav-user span { display: none; }
    
    #sidebar, #search-panel { 
        position: absolute; 
        top: 0; left: 0; bottom: 0; 
        width: 85%; 
        max-width: 320px; 
        transform: translateX(-100%); 
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    #sidebar.open, #search-panel.open { transform: translateX(0); }
    
    #ship-details { left: 10px; right: 10px; top: 60px; max-width: none; }
    #search-results { left: 10px; right: 10px; bottom: 10px; max-height: 30vh; }
    
    .mobile-menu-btn { display: block !important; background: none; border: 1px solid white; color: white; padding: 5px 10px; border-radius: 4px; margin-right: 10px; cursor: pointer; }
}

@media (min-width: 769px) {
    .mobile-menu-btn { display: none !important; }
}

/* Панель деталей судна на странице поиска */
#search-page #ship-details,
#ship-details { 
    position: absolute; 
    top: 10px; 
    right: 10px; 
    left: auto;
    background: white; 
    padding: 15px; 
    border-radius: 8px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.2); 
    z-index: 1000; 
    max-width: 320px; 
    max-height: 80vh; 
    overflow-y: auto; 
}

#ship-details button.close-btn { 
    position: absolute; 
    top: 8px; 
    right: 12px; 
    background: none; 
    border: none; 
    font-size: 20px; 
    cursor: pointer; 
    color: #666; 
}