/* Responsive shell; one rail, one header, one neutral overlay. */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0,1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: auto; border-right: 1px solid var(--line); background: var(--surface); padding: 16px 10px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.sidebar-brand { position: relative; padding: 0 6px 20px; min-height: 64px; }
.brand-mark { flex: 0 0 34px; width: 34px; height: 34px; background: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; filter: none; }
.brand-logo-dark { display: none; }
[data-theme="dark"] .brand-logo-light { display: none; }
[data-theme="dark"] .brand-logo-dark { display: block; }
.brand-copy { min-width: 0; }
.brand strong { display: block; font-size: 14px; line-height: 22px; white-space: nowrap; }
.brand span { display: block; color: var(--muted); font-size: 11px; }
.sidebar-toggle { min-height: 24px; width: 24px; height: 24px; padding: 4px; position: absolute; right: -4px; bottom: -4px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.sidebar-toggle:hover:not(:disabled) { background: var(--hover); }
.nav-menu { display: grid; grid-template-columns: minmax(0,1fr); gap: 20px; padding-top: 14px; }
.nav-group { display: grid; gap: 2px; min-width: 0; }
.nav-group-title { padding: 0 12px 4px; color: var(--muted); font-size: 11px; font-weight: 550; line-height: 20px; }
.nav-item { justify-content: flex-start; gap: 12px; width: 100%; min-height: 35px; padding: 7px 12px; background: transparent; color: var(--muted); border: 0; font-size: 14px; font-weight: 400; line-height: 22.75px; text-align: left; }
.nav-item:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--brand-tint); color: var(--brand); font-weight: 550; }
.nav-label { white-space: nowrap; line-height: 21px; }
.sidebar-account-switcher { padding: 18px 2px 4px; }
.account-switch-trigger { display: flex; width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-align: left; padding: 10px; }
.account-switcher-detail { min-width: 0; display: grid; gap: 2px; }
.account-switcher-detail strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.account-switch-action { display: none; }
.account-compact-button { display: none; }
.main { min-width: 0; padding: 0 32px 48px; }
.workspace-header { position: sticky; top: 0; z-index: 25; min-height: 72px; margin: 0 -32px 28px; padding: 12px 32px; display: flex; align-items: center; gap: 24px; background: var(--canvas); border-bottom: 1px solid var(--line); }
.page-title-block { min-width: 0; margin-right: auto; }
.page-title-row { display: flex; align-items: center; gap: 8px; }
.page-title-row h1 { white-space: nowrap; }
.header-status-stack,.header-user-area,.workspace-automation-control { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-status-stack { gap: 16px; }
.header-user-area { flex-shrink: 0; padding-left: 16px; border-left: 1px solid var(--line); }
.workspace-automation-control > span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.workspace-automation-control .title-help-button { margin-left: 0; }
.account-select { width: 160px; min-width: 100px; }
.account-select .enhanced-select-button { min-height: 34px; padding: 6px 10px; }
.header-icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; min-height: 32px; padding: 0; border: 0; background: transparent; color: var(--muted); }
.header-icon-button:hover:not(:disabled) { background: var(--hover); }
.header-refresh-icon { display: block; width: 16px; height: 16px; background: currentColor; mask: url("icons/refresh-cw.svg") center / contain no-repeat; }
.header-refresh-button.is-loading .header-refresh-icon { animation: ui-spin 1s linear infinite; }
.refresh-state-chip { display: block; font-size: 10px; color: var(--muted); line-height: 16px; }
.theme-control-button { position: relative; }
.theme-control-button [data-theme-label] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.theme-control-icon > .theme-icon-moon { display: none; }
[data-theme="dark"] .theme-control-icon > .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-control-icon > .theme-icon-moon { display: block; }
.platform-user-menu { position: relative; }
.platform-user-trigger { min-height: 34px; padding: 3px 0; gap: 8px; background: transparent; color: var(--ink); font-size: 12px; }
.platform-user-trigger:hover:not(:disabled) { background: var(--hover); }
.platform-user-avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-tint); color: var(--brand); font-size: 12px; }
.platform-user-name { max-width: 100px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mobile-menu-toggle > span:not(.nav-icon) { display: none; }
.platform-user-chevron { width: 14px; height: 14px; }
.platform-user-popover { position: absolute; top: calc(100% + 10px); right: 0; width: 224px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; z-index: 100; }
.platform-user-identity { padding: 10px 8px; display: grid; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.platform-user-identity span { color: var(--muted); font-size: 12px; }
.platform-user-actions svg,.platform-user-logout svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.platform-user-actions { display: grid; padding-top: 4px; }
.platform-user-actions button { width: 100%; justify-content: flex-start; min-height: var(--compact-height); color: var(--ink); background: transparent; border: 0; padding: 6px 8px; font-weight: 500; }
.platform-user-actions button:hover:not(:disabled) { background: var(--hover); }
.platform-user-theme-value { margin-left: auto; color: var(--muted); }
.platform-user-popover form { margin: 4px 0 0; }
.platform-user-logout { width: 100%; min-height: var(--compact-height); justify-content: flex-start; padding: 6px 8px; border: 0; border-radius: var(--radius); background: transparent; color: var(--danger); font-weight: 500; }
.platform-user-logout:hover:not(:disabled) { background: var(--danger-tint); color: var(--danger); }
.sidebar-mobile-controls,.mobile-menu-toggle { display: none; }
.sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; background: var(--drawer-scrim); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); cursor: default; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 250ms cubic-bezier(.22,1,.36,1), visibility 0s linear 350ms; }
.sidebar-backdrop:hover:not(:disabled) { background: var(--drawer-scrim); }
.app-shell.sidebar-mobile-open .sidebar-backdrop { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 250ms cubic-bezier(.22,1,.36,1), visibility 0s linear 0s; }
.content-section { display: none; width: 100%; max-width: 1232px; margin: 0 auto; min-width: 0; }
.content-section.active { display: block; }
.sidebar-collapsed { --sidebar-width: 64px; }
.sidebar-collapsed .brand-copy,.sidebar-collapsed .nav-label,.sidebar-collapsed .nav-group-title,.sidebar-collapsed .account-switch-trigger { display: none; }
.sidebar-collapsed .sidebar-brand { padding: 0 4px 26px; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 9px; }
.sidebar-collapsed .account-compact-button { display: flex; width: 100%; }
@media(min-width:1600px) { .main { padding-left: max(48px,calc((100vw - var(--sidebar-width) - 1232px)/2)); padding-right: max(48px,calc((100vw - var(--sidebar-width) - 1232px)/2)); } .workspace-header { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; } }
@media(max-width:1100px) and (min-width:769px) { .workspace-header { gap: 12px; padding-inline: 24px; margin-inline: -24px; } .main { padding-inline: 24px; } .platform-user-name { display: none; } .header-status-stack { gap: 8px; } .workspace-automation-control > span { display: none; } }
@media(max-width:768px) {
  .app-shell,.app-shell.sidebar-collapsed { display: block; --sidebar-width: 280px; }
  .sidebar { position: fixed; inset: 56px auto 0 0; width: min(288px,calc(100vw - 32px)); height: calc(100dvh - 56px); z-index: 50; display: flex; flex-direction: column; transform: translateX(-100%); visibility: hidden; transition: transform 350ms cubic-bezier(.32,.72,0,1), visibility 0s linear 350ms; padding: 12px 12px max(24px,env(safe-area-inset-bottom)); background: var(--canvas); border-right-color: var(--line-subtle); }
  .sidebar-mobile-open .sidebar { transform: translateX(0); visibility: visible; transition: transform 350ms cubic-bezier(.32,.72,0,1), visibility 0s linear 0s; }
  .sidebar-mobile-open .sidebar-backdrop { top: 56px; height: calc(100dvh - 56px); }
  /* The logo already lives in the fixed one-line app bar. Keep the drawer
     focused on the workspace selector and navigation instead of repeating it. */
  .sidebar-brand,.sidebar-collapsed .sidebar-brand { display: none; }
  .sidebar-collapsed .brand-copy,.sidebar-collapsed .nav-label,.sidebar-collapsed .nav-group-title { display: block; }
  .sidebar-collapsed .nav-item { justify-content: flex-start; padding: 6px 12px; }
  .nav-item { min-height: 35px; padding: 6px 12px; font-size: 14px; line-height: 22.75px; }
  .nav-menu { order: 3; flex: 1 1 auto; min-height: 0; gap: 22px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: auto; }
  .sidebar-brand,.sidebar-collapsed .sidebar-brand { padding: 0 6px 16px; }
  .sidebar-toggle { bottom: auto; top: 0; right: 0; width: 36px; height: 36px; min-height: 36px; border: 0; }
  .sidebar-toggle .nav-icon { display: none; }
  .sidebar-toggle::before { content: ""; width: 18px; height: 18px; background: currentColor; mask: url("icons/x.svg") center / contain no-repeat; }
  .sidebar-account-switcher { display: block; order: 1; padding: 0 0 12px; }
  .sidebar .account-compact-button { display: none; }
  .sidebar .account-switch-trigger { display: flex; align-items: center; min-height: 37px; padding: 8px 12px; background: var(--canvas); border-radius: var(--radius); }
  .sidebar .account-switcher-detail { display: block; }
  .sidebar .account-switcher-detail strong { display: block; font-size: 14px; line-height: 21px; }
  .sidebar .account-switcher-detail small { display: none; }
  .sidebar .account-switch-trigger::after { content: ""; width: 16px; height: 16px; flex: 0 0 16px; margin-left: auto; background: currentColor; opacity: .62; mask: url("icons/chevron-down.svg") center / contain no-repeat; transition: transform var(--motion), opacity var(--motion); }
  .sidebar .account-switch-trigger[aria-expanded="true"]::after { transform: rotate(180deg); opacity: 1; }
  .sidebar-mobile-controls { display: block; order: 2; padding: 0 0 12px; }
  .sidebar-mobile-controls .workspace-automation-control { display: flex; width: 100%; min-height: 35px; justify-content: space-between; padding: 6px 12px; border: 0; border-radius: var(--radius); background: transparent; }
  .main { padding: 0 16px 32px; }
  .workspace-header { margin: 0 -16px 20px; max-width: 100vw; padding: 10px 12px; gap: 6px 10px; flex-wrap: wrap; }
  .page-title-block { flex: 1; }
  .page-title-row h1 { font-size: 18px; line-height: 32px; }
  .refresh-state-chip { display: none; }
  .header-icon-button,.mobile-menu-toggle { display: inline-grid; width: 36px; height: 44px; min-height: 44px; }
  .theme-control-button { display: none; }
  .header-user-area { padding-left: 0; border: 0; gap: 6px; }
  .platform-user-name,.platform-user-chevron { display: none; }
  .platform-user-trigger { width: 36px; height: 44px; padding: 0; }
  .header-status-stack { display: none; }
  .account-select { width: auto; flex: 1; max-width: 210px; }
  .account-select .enhanced-select-button { min-height: 40px; }
  .workspace-automation-control { gap: 7px; }
  .workspace-automation-control > span { font-size: 11px; }
  .platform-user-popover { max-width: calc(100vw - 24px); }
}
@media(max-width:360px) { .main { padding-inline: 12px; } .workspace-header { margin-inline: -12px; max-width: 100vw; gap: 4px; padding-inline: 8px; } .header-icon-button { width: 32px; } .workspace-automation-control > span { display: none; } }

/* Mobile application shell: the brand bar is an app-level control row. The
   page title belongs to the content header, so it is not duplicated here. */
.mobile-shell-brand { display: none; }
@media(max-width:768px) {
  .workspace-header {
    display: grid;
    /* The reference mobile shell leads with the menu control, then places the
       compact brand mark beside it. Keep the status row below for this app's
       account context. */
    grid-template-columns: 32px 44px minmax(0,1fr) 44px;
    grid-template-areas: "menu brand tools user";
    align-items: center;
    min-height: 56px;
    row-gap: 0;
    padding: 6px 16px;
    background: var(--canvas);
  }
  .mobile-menu-toggle { grid-area: menu; }
  .mobile-menu-toggle {
    width: 32px;
    height: 32px;
    min-height: 32px;
    margin-left: 0;
    margin-right: 0;
    padding: 6px;
    border-color: transparent;
    background: transparent;
    color: var(--muted);
  }
  .mobile-menu-toggle:hover:not(:disabled) { background: var(--hover); }
  .mobile-menu-toggle[aria-expanded="true"] { border-color: var(--brand); background: transparent; color: var(--brand); }
  .mobile-menu-toggle[aria-expanded="true"] .nav-icon { display: none; }
  .mobile-menu-toggle[aria-expanded="true"]::before { content: ""; width: 18px; height: 18px; background: currentColor; mask: url("icons/x.svg") center / contain no-repeat; }
  .mobile-shell-brand {
    grid-area: brand;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
  }
  .mobile-shell-brand:hover:not(:disabled) { background: var(--hover); }
  .mobile-shell-brand-mark { display: block; width: 28px; height: 24px; }
  .mobile-shell-brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; filter: none; }
  .mobile-shell-brand-mark .brand-logo-dark { display: none; }
  [data-theme="dark"] .mobile-shell-brand-mark .brand-logo-light { display: none; }
  [data-theme="dark"] .mobile-shell-brand-mark .brand-logo-dark { display: block; }
  .page-title-block { grid-area: tools; display: flex; align-items: center; justify-content: flex-end; min-width: 0; margin: 0; }
  .page-title-row { width: 100%; justify-content: flex-end; }
  .page-title-row h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; overflow-wrap: anywhere; clip-path: inset(50%); white-space: normal; font-size: 0; line-height: 0; }
  .page-title-row .header-refresh-button { width: 44px; height: 44px; min-height: 44px; }
  .header-user-area { grid-area: user; justify-content: flex-end; width: 44px; min-width: 44px; }
  .platform-user-trigger { width: 44px; height: 44px; min-height: 44px; justify-content: center; }
  .platform-user-avatar { width: 30px; height: 30px; font-size: 12px; }
  .workspace-automation-control { min-width: 0; justify-content: flex-end; }
  .sidebar-mobile-controls .workspace-automation-control > span { display: block; }
  .workspace-automation-control .title-help-button { display: inline-grid; }
  .account-select { width: 100%; max-width: none; }
  .account-select .enhanced-select-button { min-height: 40px; }
  .platform-user-popover { top: calc(100% + 6px); right: -4px; max-width: calc(100vw - 20px); }
}
@media(max-width:360px) {
  .workspace-header { grid-template-columns: 32px 44px minmax(0,1fr) 44px; margin-inline: -16px; padding-inline: 16px; }
  .platform-user-trigger { width: 44px; }
  .mobile-shell-brand { width: 44px; }
  .mobile-shell-brand-mark { width: 28px; height: 24px; }
}
