/* ============================================================================
   App shell - E "Calm Top Bar". One white bar across the top; content sits in
   a centred column under it. Below lg (1024) the section links fold into
   #app-sidebar, which slides in as a drawer from the burger.
   ============================================================================ */
.app-frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  position: sticky;
  top: 0;
  /* Above the sticky sync banner and page furniture, so the search results,
     account menu and phone drawer (all inside the bar) open over them. Below
     the confirm dialog and toasts (--z-modal, --z-toast). */
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 28px;
  /* Never shrinks: the orders and vendors pages cap the frame at the viewport,
     and a flex item that may shrink gave up 20px to the table there. */
  flex: none;
  height: var(--topbar-height);
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--line);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  font-weight: 600;
}

.brand small {
  margin-top: 2px;
  color: var(--faint);
  font-size: 12px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--accent);
}

.brand-mark svg {
  width: 17px;
  height: 17px;
  display: block;
}

.topbar-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: -8px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.topbar-burger:hover { background: var(--hover); }
.topbar-burger:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }

/* The store, not the product, names the app here - the merchant knows which
   app they opened; what they need is which store it's pointed at. */
.topbar-brand {
  flex: none;
  gap: 10px;
  min-height: 0;
  padding: 0;
  border-bottom: 0;
  max-width: 220px;
}
.topbar-brand .brand-mark { flex: none; }
.topbar-brand .brand-text { min-width: 0; }
.topbar-brand strong {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-nav {
  flex: 1;
  min-width: 0;
  align-self: stretch;
}

.nav-stack {
  display: flex;
  align-items: stretch;
  gap: 24px;
  height: 100%;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav-link:hover { color: var(--text); }
.nav-link.is-active { color: var(--text); border-bottom-color: var(--accent); }
/* Section links are words in the bar; the icons are for the drawer. */
.nav-link .nav-icon { display: none; flex: none; }

/* Support and Settings: icon buttons at the bar's right end. */
.nav-link--util {
  align-self: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-bottom: 0;
  border: 1px solid var(--control-line);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.nav-link--util + .nav-link--util { margin-left: -16px; }
.nav-link--util .nav-icon { display: block; width: 17px; height: 17px; }
.nav-link--util .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav-link--util:hover { background: var(--hover); }
.nav-link--util.is-active { background: var(--text); border-color: var(--text); color: #fff; }

.nav-link.is-locked .nav-label { color: var(--muted); opacity: 0.72; }
.nav-crown { margin-left: 2px; }
.nav-link.is-active .crown-icon { color: currentColor; }

/* Failed background jobs, counted on Settings (where their list lives). Shown to
   the operator only, and only while something is failing. On the icon button
   it sits on the corner. */
.nav-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-link--util .nav-count {
  position: absolute;
  top: -7px;
  right: -7px;
  box-shadow: 0 0 0 2px var(--panel);
}

/* ---- Search: jump to a page, or search orders for what was typed. */
.topbar-search {
  position: relative;
  align-self: center;
  margin-left: auto;
}
.topbar-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 280px;
  height: 36px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-subtle);
  color: var(--faint);
  cursor: text;
}
.topbar-search-field:focus-within { border-color: var(--accent); outline: 2px solid var(--accent-weak); background: var(--panel); }
.topbar-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.topbar-search-input::-webkit-search-cancel-button { display: none; }
.topbar-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--panel);
}
.jump-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  width: 340px;
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
.jump-results[hidden] { display: none; }
.jump-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.jump-option small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.jump-option[aria-selected="true"] { background: var(--accent-weak); }

/* ---- Account menu: the avatar opens who you're signed in as + a few links. */
.topbar-account { position: relative; flex: none; }
.topbar-account > summary { list-style: none; cursor: pointer; }
.topbar-account > summary::-webkit-details-marker { display: none; }
.app-topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--text);
  overflow: hidden;
}
.app-topbar-avatar:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }
.app-topbar-avatar.has-logo { background: #fff; padding: 4px; border: 1px solid var(--line); }
.app-topbar-avatar.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 260px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  display: grid;
}
.account-menu-who {
  display: grid;
  gap: 2px;
  padding: 10px 10px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}
.account-menu-who strong { color: var(--text); font-size: 14px; font-weight: 600; }
.account-menu-who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-domain { color: var(--faint); font-size: 12px; }
.account-menu a { padding: 8px 10px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text); }
.account-menu a:hover { background: var(--hover); }

.nav-scrim { display: none; }

/* On the pages that fill the viewport (orders, vendors) the page content is the
   scroll container, and the top bar isn't inside it - so the sync banner pins
   at 0 there, not under the bar. */
body:has(.orders-page) .sync-banner,
body:has(.vendors-page.is-fill) .sync-banner { top: 0; }

.workspace {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
}

/* 1024-1279: the links need the room, so the search collapses to its icon and
   opens over the links when focused. */
@media (min-width: 1024px) and (max-width: 1279px) {
  .app-topbar { gap: 22px; }
  .nav-stack { gap: 20px; }
  .topbar-search-field { width: 36px; padding: 0; justify-content: center; gap: 0; }
  /* Collapsed, not display:none - a hidden input can't take the focus the
     label click hands it, and focus is what opens it. */
  .topbar-search-field .topbar-search-input { flex: 0 0 0; width: 0; opacity: 0; }
  .topbar-search-field .topbar-kbd { display: none; }
  .topbar-search-field:focus-within {
    position: absolute;
    right: 0;
    top: -18px;
    width: 300px;
    padding: 0 10px 0 12px;
    justify-content: flex-start;
    z-index: 51;
  }
  .topbar-search-field:focus-within { gap: 8px; }
  .topbar-search-field:focus-within .topbar-search-input { flex: 1; width: auto; opacity: 1; }
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.page-content {
  display: grid;
  gap: 16px;
  /* E: a centred column. Pages read best at a measure, not stretched across a
     27-inch monitor; the tool pages below opt back out to the full width. */
  width: 100%;
  max-width: calc(var(--content-max) + 2 * var(--page-gutter));
  margin: 0 auto;
  padding: 32px var(--page-gutter) 48px;
}

/* Tool pages - wide tables and side-by-side editors - use the whole width. */
.page-content:has(.orders-page, .vendors-page, .dlv-page, .editor-topbar, .bb-editor) {
  max-width: none;
  padding-top: 20px;
}

@media (max-width: 1023px) {
  .page-content { padding-top: 20px; }
}

@media (max-width: 767px) {
  :root { --page-gutter: 12px; }
}

