/* Responsive header and navigation for the cloud preview. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.app,
.main,
.content {
  min-width: 0;
  width: 100%;
}

.topbar {
  height: auto;
  min-height: 72px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 20px;
}

.topbar-heading {
  flex: 1 1 180px;
  min-width: 0;
}

.topbar-title-copy {
  min-width: 0;
}

.topbar-actions {
  flex: 1 1 360px !important;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end !important;
}

.global-search {
  flex: 1 1 250px;
  min-width: 0;
}

.global-search input {
  min-width: 0 !important;
  flex: 1 1 auto;
}

.topbar-actions .userpill {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

#cloudUserLabel {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#cloudSyncStatus {
  white-space: nowrap;
}

.content {
  max-width: 1600px;
}

@media (max-width: 1000px) {
  .topbar {
    padding: 10px 16px;
  }

  .topbar-actions {
    flex-basis: 310px !important;
  }
}

@media (max-width: 680px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .topbar-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .topbar-actions {
    display: flex;
    flex: none !important;
    width: 100%;
    gap: 8px;
    justify-content: space-between !important;
  }

  .global-search {
    flex: 1 1 100%;
    width: 100%;
    max-width: none !important;
  }

  .topbar-actions .userpill {
    flex: 0 0 100%;
    justify-content: flex-end;
  }

  .topbar h2 {
    font-size: 18px;
  }

  .topbar .sub {
    font-size: 11px;
  }

  .mobilemenu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 42px;
    min-height: 40px;
    padding: 8px 11px;
    color: white;
    background: var(--navy);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 101;
    display: flex !important;
    flex-direction: column;
    width: min(290px, 85vw) !important;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 20px;
    box-shadow: 8px 0 24px #10263b33;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-scrim {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border-radius: 0;
    background: #0e2236a8;
  }

  .mobile-scrim[hidden] {
    display: none !important;
  }

  .sidefoot {
    position: static;
    margin-top: auto;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  .content {
    padding: 17px 13px;
  }

  .pagehead {
    display: block;
  }

  .pagehead .actions {
    margin-top: 14px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .stat {
    min-width: 0;
    padding: 13px;
  }

  .stat strong {
    font-size: 23px;
  }

  .stat-top {
    font-size: 11px;
  }

  .formgrid,
  .reportgrid {
    grid-template-columns: minmax(0, 1fr);
  }

  .field.full {
    grid-column: auto;
  }

  .modalbody,
  .modalhead,
  .modalfoot {
    padding: 16px;
  }
}

@media (max-width: 380px) {
  .stats {
    grid-template-columns: minmax(0, 1fr);
  }

  #cloudUserLabel {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}
