/* Header B (owner, Nov 11): "Slim app bar + slim page bar".
   1. A 48px navy app bar runs across the very top, above the sidebar and the page: the brand (the sidebar's collapse button, moved
      here), a search field, notification settings, help and the account menu. It is the first row of the workspace window, outside the
      page's scroll area, so it never moves.
   2. The page's thin bar (the one page header, the h1 and its buttons) also stays at the top of the page while it scrolls, and holds
      the page's view tabs right after the page name. Long tables' column headers stick under it.
   --tr-app-bar-h is the app bar's height. --tr-sticky-top is the height of whatever stays in view at the top of the page's own scroll
   area (the page bar; on phones only its tabs row). app-workspace-bars.js measures it on .workspace-content and every sticky offset
   inside the page (column headers, scroll padding) uses it. Sticky offsets count from the inside of the page's top padding, so they
   subtract --tr-scroll-pad (that padding, also measured).
   Phones (UI #179): the app bar is "☰ Menu | page name" with a search button and the avatar; the tabs row stays under it and scrolls
   sideways. Tokens only. Dialogs, drawers and pop-ups keep their own layers above both bars. */
#appShell.ui-workspace{--tr-app-bar-h:48px;--tr-rail-w:224px;--tr-drop:color-mix(in srgb,var(--ui-navy) 34%,transparent)}
#appShell.ui-workspace[data-ui-theme="dark"]{--tr-drop:color-mix(in srgb,#000 70%,transparent)}
#appShell.ui-workspace.is-sidebar-collapsed{--tr-rail-w:74px}
#appShell.ui-workspace.ui-workspace .workspace-window{grid-template-rows:var(--tr-app-bar-h) minmax(0,1fr)}
#appShell.ui-workspace.ui-workspace :is(.workspace-sidebar,.main-shell){grid-row:2}
#appShell.ui-workspace.ui-workspace .workspace-sidebar{border-top:1px solid var(--ui-band-line);padding-top:12px}
#appShell.ui-workspace.ui-workspace.is-sidebar-collapsed .workspace-sidebar{padding-top:12px}

/* The app bar. */
#appShell.ui-workspace .workspace-app-bar{grid-column:1 / -1;grid-row:1;position:relative;z-index:30;display:flex;align-items:center;gap:12px;min-width:0;height:var(--tr-app-bar-h);padding:0 12px 0 0;background:var(--ui-navy);color:var(--ui-band-nav);-webkit-print-color-adjust:exact;print-color-adjust:exact}
#appShell.ui-workspace .workspace-app-bar :is(button,a,input):focus-visible{outline:2px solid var(--ui-band-strong);outline-offset:-2px}
#appShell.ui-workspace .workspace-app-bar .workspace-app-popover :is(button,a):focus-visible{outline-color:var(--ui-blue)}
#appShell.ui-workspace .workspace-app-bar-brand{display:flex;align-items:center;flex:none;width:var(--tr-rail-w);height:100%;padding:0 12px;box-sizing:border-box}
#appShell.ui-workspace.ui-workspace .workspace-app-bar .workspace-brand{width:auto;max-width:100%;height:36px;min-height:0;margin:0;padding:0 8px 0 4px;gap:9px;border-radius:8px;color:var(--ui-band-strong)}
#appShell.ui-workspace.ui-workspace .workspace-app-bar .workspace-brand:hover:not(:disabled){background:color-mix(in srgb,var(--ui-band-strong) 8%,transparent)}
#appShell.ui-workspace.ui-workspace.is-sidebar-collapsed .workspace-app-bar .workspace-brand{padding:0 4px}
#appShell.ui-workspace.ui-workspace .workspace-app-bar .workspace-brand-mark{width:28px;height:28px;border-radius:8px}
#appShell.ui-workspace.ui-workspace .workspace-app-bar .workspace-brand-mark svg{width:19px;height:19px}
#appShell.ui-workspace.ui-workspace .workspace-app-bar .workspace-brand-copy{display:grid;grid-auto-flow:column;align-items:baseline;gap:8px;white-space:nowrap}
#appShell.ui-workspace.ui-workspace .workspace-app-bar .workspace-brand-name{color:var(--ui-band-strong);font-size:var(--type-body)}
#appShell.ui-workspace.ui-workspace .workspace-app-bar .workspace-brand-version{color:var(--ui-band-muted)}
#appShell.ui-workspace .workspace-app-bar > .workspace-phone-bar{display:none}

/* Search: Enter opens the Search page with the words typed (app-workspace-bars.js). */
#appShell.ui-workspace .workspace-app-search{position:relative;display:flex;align-items:center;flex:1 1 auto;min-width:0;max-width:520px;margin:0 auto}
#appShell.ui-workspace .workspace-app-search[hidden]{display:none}
#appShell.ui-workspace .workspace-app-search .workspace-app-search-icon{position:absolute;left:10px;width:16px;height:16px;fill:none;stroke:var(--ui-band-muted);stroke-width:1.8;stroke-linecap:round;pointer-events:none}
#appShell.ui-workspace.ui-workspace .workspace-app-search input{width:100%;height:32px;min-height:32px;margin:0;padding:0 34px 0 32px;border:1px solid var(--ui-band-line);border-radius:8px;background:color-mix(in srgb,var(--ui-band-strong) 7%,transparent);box-shadow:none;color:var(--ui-band-strong);font-size:var(--type-body)}
#appShell.ui-workspace.ui-workspace .workspace-app-search input::placeholder{color:var(--ui-band-muted);opacity:1}
#appShell.ui-workspace.ui-workspace .workspace-app-search input:hover{background:color-mix(in srgb,var(--ui-band-strong) 11%,transparent)}
#appShell.ui-workspace.ui-workspace .workspace-app-search input:focus{border-color:var(--ui-band-line-strong);background:color-mix(in srgb,var(--ui-band-strong) 11%,transparent)}
#appShell.ui-workspace .workspace-app-search kbd{position:absolute;right:8px;padding:0 5px;border:1px solid var(--ui-band-line-strong);border-radius:5px;color:var(--ui-band-muted);font:var(--type-caption)/18px var(--ui-font-sans);pointer-events:none}
#appShell.ui-workspace .workspace-app-search:focus-within kbd{display:none}

/* Right side: notification settings, help, account. As wide as the brand side so the search sits in the middle. */
#appShell.ui-workspace .workspace-app-actions{display:flex;align-items:center;justify-content:flex-end;gap:4px;flex:none;min-width:calc(var(--tr-rail-w) - 12px)}
/* With search hidden (a plan without Search), the icons stay at the right instead of sliding next to the logo. */
#appShell.ui-workspace .workspace-app-search[hidden] ~ .workspace-app-actions{margin-left:auto}
#appShell.ui-workspace.ui-workspace .workspace-app-icon{display:inline-flex;align-items:center;justify-content:center;width:32px;min-width:32px;height:32px;min-height:32px;margin:0;padding:0;border:0;border-radius:8px;background:none;box-shadow:none;color:var(--ui-band-nav);cursor:pointer}
#appShell.ui-workspace.ui-workspace .workspace-app-icon:is(:hover,[aria-expanded="true"]){background:color-mix(in srgb,var(--ui-band-strong) 8%,transparent);color:var(--ui-band-strong)}
#appShell.ui-workspace .workspace-app-icon svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
#appShell.ui-workspace.ui-workspace .workspace-app-icon[hidden],#appShell.ui-workspace.ui-workspace .workspace-app-icon.workspace-app-search-open{display:none}
#appShell.ui-workspace .workspace-app-sep{width:1px;height:22px;margin:0 4px;background:var(--ui-band-line)}
#appShell.ui-workspace .workspace-app-menu{position:relative;display:inline-flex}
#appShell.ui-workspace.ui-workspace .workspace-app-account{display:inline-flex;align-items:center;justify-content:center;min-width:0;min-height:0;margin:0;padding:2px;border:0;border-radius:999px;background:none;box-shadow:none;cursor:pointer}
#appShell.ui-workspace.ui-workspace .workspace-app-account:is(:hover,[aria-expanded="true"]){background:color-mix(in srgb,var(--ui-band-strong) 8%,transparent)}
#appShell.ui-workspace .workspace-app-avatar{position:relative;display:grid;place-items:center;width:30px;height:30px;border-radius:50%;background:var(--ui-band-fill);color:var(--ui-band-strong);font-size:var(--type-caption);font-weight:650;letter-spacing:.02em}
/* A customer's logo keeps a white plate, as in the sidebar before. */
#appShell.ui-workspace .workspace-app-avatar.has-logo{background:#fff}
#appShell.ui-workspace .workspace-app-avatar img{width:100%;height:100%;border-radius:inherit;object-fit:contain;display:block}
/* UI #129: a System status problem shows as a dot on the avatar. */
#appShell.ui-workspace .workspace-app-avatar .workspace-profile-system-dot{position:absolute;right:-2px;top:-2px;width:10px;height:10px;border-radius:50%;border:2px solid var(--ui-navy);background:var(--near)}
#appShell.ui-workspace .workspace-app-avatar .workspace-profile-system-dot[hidden]{display:none}
#appShell.ui-workspace .workspace-app-avatar .workspace-profile-system-dot.is-outage{background:var(--err)}
#appShell.ui-workspace .workspace-app-avatar .workspace-profile-system-dot:is(.is-downloads,.is-disconnected){background:var(--warn)}

/* Pop-ups under the help and account buttons: a raised surface with the page's own colours. */
#appShell.ui-workspace .workspace-app-popover{position:absolute;top:calc(100% + 8px);right:0;z-index:50;display:flex;flex-direction:column;gap:2px;min-width:240px;max-width:min(320px,calc(100vw - 24px));box-sizing:border-box;padding:6px;border:1px solid var(--ui-line-strong);border-radius:10px;background:var(--ui-surface-solid);box-shadow:var(--ui-shadow-md);color:var(--ui-ink);text-align:left}
#appShell.ui-workspace .workspace-app-popover[hidden]{display:none}
#appShell.ui-workspace.ui-workspace .workspace-app-popover-item{display:flex;align-items:center;gap:8px;width:100%;min-height:36px;height:auto;margin:0;padding:8px 10px;border:0;border-radius:7px;background:none;box-shadow:none;color:var(--ui-ink);font-size:var(--type-body);font-weight:500;text-align:left;text-decoration:none;cursor:pointer}
#appShell.ui-workspace.ui-workspace .workspace-app-popover-item:hover{background:var(--ui-surface-muted)}
#appShell.ui-workspace.ui-workspace .workspace-app-popover a.workspace-app-popover-item{margin-top:4px;padding-top:10px;border-top:1px solid var(--ui-line);border-radius:0 0 7px 7px;color:var(--ui-blue)}

/* Account menu: the former sidebar-bottom profile button (name, Profile & account, plan) and the Dark appearance switch, moved here. */
/* app-workspace-profile.js builds them in the sidebar and app-workspace-bars.js moves them here a moment later; never draw them in the sidebar meanwhile. */
#appShell.ui-workspace #workspaceSidebar :is(.workspace-profile-anchor,.workspace-sidebar-footer){display:none}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .workspace-profile-anchor{display:flex;flex-direction:column;align-items:stretch;gap:2px;margin:0;padding:0;border:0}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .workspace-profile-button{display:grid;grid-template-columns:32px minmax(0,1fr) auto;align-items:center;gap:2px 10px;width:100%;padding:8px 10px;border-radius:7px;color:var(--ui-ink)}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .workspace-profile-button:hover{background:var(--ui-surface-muted)}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .workspace-profile-avatar{grid-row:1;background:var(--ui-blue-soft);color:var(--ui-blue)}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .workspace-profile-avatar.has-logo{background:#fff;border-color:var(--ui-line)}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu :is(.workspace-profile-copy,.workspace-profile-plan){display:grid}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .workspace-profile-plan{grid-column:3;grid-row:1;justify-self:end;max-width:none;padding:3px 6px;color:var(--ui-ink-secondary);background:var(--ui-surface-muted)}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .workspace-profile-system-dot{display:none}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .workspace-account-controls{display:block;margin:4px 0 0;padding:4px 0 0;border-top:1px solid var(--ui-line)}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .app-theme-toggle{display:flex;align-items:center;justify-content:flex-start;gap:10px;width:100%;height:auto;min-height:36px;padding:8px 10px;border:0;border-radius:7px;background:none;color:var(--ui-ink);font-size:var(--type-body);font-weight:500;text-align:left}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .app-theme-toggle:hover{background:var(--ui-surface-muted)}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .app-theme-toggle svg{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .app-theme-toggle::after{content:"Off";margin-left:auto;color:var(--ui-ink-secondary);font-size:var(--type-caption)}
#appShell.ui-workspace.ui-workspace.ui-workspace .workspace-account-menu .app-theme-toggle[aria-pressed="true"]::after{content:"On"}

/* The page bar stays at the top of the page while it scrolls. Its background reaches the page edges (::before, painted into the
   side gutters with offset shadows, which never widen the page), and a soft shadow shows once something is under it. The tracking pages' hairline (::after) is unchanged. */
#appShell#appShell.ui-workspace .workspace-content > .pane-transition > .tr-page-head:not([hidden]){position:sticky;top:calc(var(--tr-page-bar-top,0px) - var(--tr-scroll-pad,0px));z-index:12}
#appShell#appShell.ui-workspace .workspace-content > .pane-transition > .tr-page-head:not([hidden])::before{content:"";position:absolute;z-index:-1;inset:0;--tr-gutter:var(--page-pad-x,32px);background:var(--ui-page-flat);box-shadow:calc(-1 * var(--tr-gutter)) 0 0 0 var(--ui-page-flat),var(--tr-gutter) 0 0 0 var(--ui-page-flat);transition:box-shadow .15s ease;pointer-events:none}
#appShell#appShell.ui-workspace .workspace-content[data-tr-scrolled] > .pane-transition > .tr-page-head:not([hidden])::before{box-shadow:calc(-1 * var(--tr-gutter)) 0 0 0 var(--ui-page-flat),var(--tr-gutter) 0 0 0 var(--ui-page-flat),0 10px 14px -12px var(--tr-drop),calc(-1 * var(--tr-gutter)) 10px 14px -12px var(--tr-drop),var(--tr-gutter) 10px 14px -12px var(--tr-drop)}
#appShell.ui-workspace.ui-workspace .workspace-content{scroll-padding-top:calc(var(--tr-sticky-top,0px) + 24px)}

/* The page's view tabs sit in the bar right after the page name, after a short divider; the buttons stay on the right. */
#appShell.ui-workspace .tr-page-head > .tr-page-head-copy:has(+ .tr-page-head-tabs:not(:empty)){margin-inline-end:0}
#appShell.ui-workspace .tr-page-head > .tr-page-head-tabs{display:flex;align-items:center;gap:14px;flex:0 1 auto;min-width:0;margin:0 auto 0 4px;order:0}
#appShell.ui-workspace .tr-page-head > .tr-page-head-tabs:empty{display:none}
#appShell.ui-workspace .tr-page-head > .tr-page-head-tabs::before{content:"";flex:none;width:1px;height:20px;background:var(--tracking-line,var(--ui-line))}
#appShell.ui-workspace.ui-workspace.ui-workspace .tr-page-head > .tr-page-head-tabs > *{flex:0 1 auto;min-width:0;max-width:100%;margin:0;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
#appShell.ui-workspace.ui-workspace.ui-workspace .tr-page-head > .tr-page-head-tabs > ::-webkit-scrollbar{display:none}
@media(pointer:fine){
  body[data-app-shell]:not(#_) #appShell.ui-workspace .tr-page-head > .tr-page-head-tabs > * > button:not([hidden]), body #appShell.ui-workspace #appShell.ui-workspace .tr-page-head > .tr-page-head-tabs > * > button:not([hidden]){min-height:30px;padding-block:3px}
}
/* Tracking pages' underline tabs: the underline sits on the bar's own hairline. */
#appShell.ui-workspace.ui-workspace.ui-workspace :is(#paneMissing,#paneSeasonSeats,#paneCanceledEvents,#paneCreditCards,#paneMpTags,#paneTerms) > .tr-page-head > .tr-page-head-tabs{align-self:stretch;margin-block:-9px}
#appShell.ui-workspace.ui-workspace.ui-workspace.ui-workspace :is(#paneMissing,#paneSeasonSeats,#paneCanceledEvents,#paneCreditCards,#paneMpTags,#paneTerms) > .tr-page-head > .tr-page-head-tabs > *{align-self:stretch;align-items:center;margin-bottom:0}
/* A view bar whose tabs moved up is left empty; Missing Charges keeps its "Last added" line and Security its Refresh link. */
#appShell.ui-workspace.ui-workspace :is(.cards-viewbar,.cancel-viewbar,.term-viewbar,.season-viewbar,.tags-viewbar):not(:has(> :not([hidden]))){display:none}
#appShell.ui-workspace.ui-workspace #paneMissing .missing-viewbar:not(:has(.missing-status-chips)){justify-content:flex-end;min-height:0}
#appShell.ui-workspace.ui-workspace #paneConnections.connections-studio .cs-command:not(:has(.cs-filters)){justify-content:flex-end}

/* Long tables: a table box that does not scroll sideways stops being its own scroll area (app-workspace-bars.js marks it), so the
   column headers stick under the page bar. Boxes that really scroll sideways keep their scrolling and their headers stick inside them. */
#appShell#appShell#appShell.ui-workspace [data-tr-sticky-pass] > table > thead > tr:first-child > th,
#appShell#appShell#appShell.ui-workspace [data-tr-sticky-pass] > * > table > thead > tr:first-child > th{position:sticky;top:calc(var(--tr-sticky-top,0px) - var(--tr-scroll-pad,0px))}

/* Below 1180px the brand and the right side take only what they need. */
@media(max-width:1180px) and (min-width:761px){
  #appShell.ui-workspace .workspace-app-actions{min-width:0}
  #appShell.ui-workspace .workspace-app-search{margin:0 12px}
}

/* Phones (UI #179): the app bar is the Menu bar. Menu, a divider and the page name on the left; search and the avatar on the right. */
@media(max-width:760px){
  #appShell.ui-workspace{--tr-app-bar-h:52px}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-window{grid-template-rows:var(--tr-app-bar-h) minmax(0,1fr)}
  #appShell.ui-workspace.is-phone-nav .workspace-app-bar{padding:0 10px 0 6px;gap:6px}
  #appShell.ui-workspace.is-phone-nav .workspace-app-actions{min-width:0}
  #appShell.ui-workspace.is-phone-nav :is(.workspace-app-bar-brand,.workspace-app-search,#workspaceAppNotifications,.workspace-app-menu:has(#workspaceAppHelp),.workspace-app-sep){display:none}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-app-bar > .workspace-phone-bar{display:flex;align-items:center;gap:8px;flex:1 1 auto;min-width:0;padding:0;border:0;background:none}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-app-bar .workspace-phone-menu{display:inline-flex;align-items:center;gap:6px;min-height:44px;height:44px;padding:0 10px;border:0;border-radius:8px;background:none;box-shadow:none;color:var(--ui-band-strong);font-weight:500}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-app-bar .workspace-phone-menu:hover{background:color-mix(in srgb,var(--ui-band-strong) 8%,transparent)}
  #appShell.ui-workspace .workspace-phone-bar-line{flex:none;width:1px;height:20px;background:var(--ui-band-line-strong)}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-app-bar #workspacePhoneTitle{color:var(--ui-band-strong);font-size:var(--type-section)}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-app-search-open:not([hidden]){display:inline-flex;width:44px;min-width:44px;height:44px;min-height:44px}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-app-account{padding:7px}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-app-avatar{width:30px;height:30px}
  #appShell.ui-workspace.is-phone-nav .workspace-app-popover{position:fixed;top:calc(var(--tr-app-bar-h) + 6px);right:12px}
  #appShell.ui-workspace.ui-workspace.is-phone-nav .workspace-sidebar{border-top:0;padding-top:16px}
  /* The page bar: the page name and buttons scroll away (the app bar shows the name); the tabs row comes last and stays under the app bar,
     scrolling sideways. app-workspace-bars.js sets --tr-page-bar-top to minus the height above the tabs. */
  #appShell.ui-workspace .tr-page-head > .tr-page-head-tabs{order:4;flex:1 1 100%;margin:0}
  #appShell.ui-workspace .tr-page-head > .tr-page-head-tabs::before{display:none}
  #appShell.ui-workspace.ui-workspace.ui-workspace :is(#paneMissing,#paneSeasonSeats,#paneCanceledEvents,#paneCreditCards,#paneMpTags,#paneTerms) > .tr-page-head > .tr-page-head-tabs{margin-block:0 -9px}
  body[data-app-shell]:not(#_) #appShell.ui-workspace .tr-page-head > .tr-page-head-tabs > *, body #appShell.ui-workspace #appShell.ui-workspace .tr-page-head > .tr-page-head-tabs > *{flex-wrap:nowrap;overflow-x:auto;width:max-content;max-width:100%}
}
@media print{
  #appShell.ui-workspace .workspace-app-bar{display:none}
}
