:root {
  --pf-mobile-nav-height: 4.35rem;
  --pf-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

.connection-status {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 2000;
  transform: translate(-50%, -120%);
  min-width: min(92vw, 30rem);
  padding: .62rem 1rem;
  border-radius: 0 0 .9rem .9rem;
  background: #7f1d1d;
  color: #fff;
  font-size: .88rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 .4rem 1.2rem rgba(15, 23, 42, .24);
  transition: transform .2s ease;
}

.connection-status.is-visible {
  transform: translate(-50%, 0);
}

.pwa-install-card {
  display: none;
  border: 1px solid rgba(13, 110, 253, .2);
  background: linear-gradient(135deg, rgba(13, 110, 253, .08), rgba(25, 135, 84, .08));
}

.pwa-install-card.is-visible {
  display: block;
}

.pwa-ios-card {
  display: none;
}

.pwa-ios-card.is-visible {
  display: block;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-quick-menu .offcanvas-body {
  padding-bottom: calc(1.25rem + var(--pf-safe-bottom));
}

.mobile-quick-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3.25rem;
  padding: .75rem .9rem;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: .9rem;
  color: #111827;
  background: #fff;
  text-decoration: none;
}

.mobile-quick-link:hover,
.mobile-quick-link:focus {
  color: #0d6efd;
  border-color: rgba(13, 110, 253, .3);
  background: rgba(13, 110, 253, .04);
}

.pwa-update-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 2050;
  display: none;
  width: min(92vw, 24rem);
  padding: .85rem;
  border-radius: .9rem;
  background: #111827;
  color: #fff;
  box-shadow: 0 .65rem 1.8rem rgba(15, 23, 42, .28);
}

.pwa-update-toast.is-visible {
  display: block;
}

@media (max-width: 991.98px) {
  body.authenticated-app {
    padding-bottom: calc(var(--pf-mobile-nav-height) + var(--pf-safe-bottom));
  }

  .page-content main,
  main.container-fluid {
    padding-top: 1rem !important;
    padding-left: .85rem !important;
    padding-right: .85rem !important;
  }

  .mobile-topbar {
    min-height: 3.55rem;
  }

  .mobile-topbar .navbar-brand {
    max-width: 52vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
  }

  .mobile-topbar .mobile-user-name {
    max-width: 25vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    min-height: calc(var(--pf-mobile-nav-height) + var(--pf-safe-bottom));
    padding: .35rem .35rem calc(.35rem + var(--pf-safe-bottom));
    border-top: 1px solid rgba(15, 23, 42, .12);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -.35rem 1rem rgba(15, 23, 42, .08);
    backdrop-filter: blur(14px);
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .18rem;
    min-width: 0;
    min-height: 3.45rem;
    padding: .28rem .2rem;
    border: 0;
    border-radius: .8rem;
    color: #64748b;
    background: transparent;
    text-decoration: none;
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.1;
  }

  .mobile-bottom-nav .mobile-nav-icon {
    font-size: 1.16rem;
    line-height: 1;
  }

  .mobile-bottom-nav a.active,
  .mobile-bottom-nav button.active {
    color: #0d6efd;
    background: rgba(13, 110, 253, .08);
  }

  .card,
  .content-card {
    border-radius: 1rem;
  }

  .card-body {
    padding: 1rem;
  }

  .btn,
  .form-control,
  .form-select,
  .input-group-text {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 38px;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  textarea {
    min-height: 7rem;
  }

  .table-responsive {
    margin-right: -.25rem;
    margin-left: -.25rem;
    padding-right: .25rem;
    padding-left: .25rem;
    border-radius: .8rem;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 42rem;
  }

  .table.table-mobile-compact {
    min-width: 34rem;
  }

  .table td,
  .table th {
    vertical-align: middle;
  }

  .table .btn,
  .table form .btn {
    white-space: nowrap;
  }

  .page-actions,
  .card-actions,
  .mobile-stack-actions {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: .55rem !important;
  }

  .page-actions > *,
  .card-actions > *,
  .mobile-stack-actions > * {
    width: 100%;
  }

  .modal-dialog {
    margin: .65rem;
  }

  .offcanvas {
    max-width: 90vw;
  }
}

@media (display-mode: standalone) {
  .pwa-browser-only {
    display: none !important;
  }

  .mobile-topbar,
  .topbar-menu {
    padding-top: env(safe-area-inset-top, 0px);
  }
}
