/* App header: sync status and the account avatar at the top right of every
   page (sign out and profile live in the avatar's menu).
   Desktop: pinned to the same corner of the content area on every page,
   beside the page title, so it costs no height (the calendar month grid is
   fitted to the window and needs every row).
   Phones: a full bar across the top with the CashWeeks mark on the left. */

main {
  position: relative;
}

#appHeader.app-header {
  position: absolute;
  z-index: 20;
  top: 14px;
  right: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 0;
  padding: 0;
}

/* Keep the title block clear of the avatar corner. */
#appHeader + .topbar {
  padding-right: 240px;
}

#appHeader .app-header-brand {
  display: none;
}

/* The shell is a plain row here, on every page and width (older page rules
   turned it into grid cells inside the title block). */
#appHeader .top-actions-shell,
body[data-page] #appHeader .top-actions-shell {
  display: flex !important;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: auto;
  margin: 0 0 0 auto;
}

body[data-page] #appHeader .top-actions-shell .sync-status-button,
body[data-page] #appHeader .top-actions-shell .auth-button {
  grid-column: auto;
  grid-row: auto;
  margin: 0;
}

/* Account: the avatar alone, 44px round; name and email stay in its menu. */
#appHeader .auth-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  box-shadow: none;
  cursor: pointer;
}

#appHeader .auth-button .auth-avatar {
  width: 36px;
  height: 36px;
  margin: 0;
  border-radius: 50%;
}

#appHeader .auth-button .auth-button-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#appHeader .auth-button:hover {
  border-color: color-mix(in srgb, var(--green) 45%, var(--line));
}

#appHeader .auth-button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

#appHeader .auth-button[aria-expanded="true"] {
  border-color: var(--green);
}

#appHeader .auth-invite-dot {
  top: 0;
  right: 0;
}

#appHeader .auth-premium-mark {
  top: -6px;
  right: -6px;
}

/* The title block now has the full width. */
.topbar {
  display: block;
}

@media (max-width: 720px) {
  #appHeader.app-header {
    position: static;
    justify-content: space-between;
    min-height: 52px;
    margin: 0 0 12px;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--line);
  }

  #appHeader + .topbar {
    padding-right: 0;
  }

  #appHeader .app-header-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    color: var(--ink);
    font: 800 17px/1 Manrope, sans-serif;
    text-decoration: none;
  }

  #appHeader .app-header-brand img {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }

  #appHeader .app-header-brand > span > span {
    color: var(--green);
  }

  #appHeader .app-header-brand:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    border-radius: 8px;
  }

  /* Phones: the sync button is a compact dot + short label. */
  #appHeader .sync-status-button {
    min-height: 44px;
    max-width: 52vw;
  }

  #appHeader .sync-status-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media print {
  #appHeader.app-header {
    display: none;
  }
}
