Redirect to /login instead of /panel/login

I want to show custom login page for panel users. I do:

        'route:before' => function ($route, $path, $method) {
          if (str_starts_with($path, 'panel') && kirby()->user() === NULL) {
            $url = Url::to('/login');
            return go($url);
          }
        },

whick works sometimes, but does not work on API requests (eg. after logout), or on redirect. I tried additionally ckeck api requests:

          if (str_starts_with($path, 'api/panel') && kirby()->user() === NULL) {
            $url = Url::to('/login');
            return [
              'status' => 200,
              'href' => $url,
            ];
          }

with little success, because sometimes they comes as ‘api/system?view=panel’, sometimes as ‘api/panel’.

What would be correct way to have custom panel login page? I need 2 more “required” fields on panel login.

You can create a custom login view instead?