/* BobaLive navigation refactor candidate. Preserve existing dark/gold tokens. */

#app-shell {
  min-height: 100dvh;
  grid-template-columns: 236px minmax(0, 1fr) !important;
  overflow: visible !important;
}

body:not(.mobile-mode) #app-shell {
  overflow: visible !important;
}

#app-shell.sidebar-collapsed {
  grid-template-columns: 68px minmax(0, 1fr) !important;
}

#app-shell.sidebar-collapsed > .sidebar {
  width: 68px !important;
}

body:not(.mobile-mode) #app-shell.sidebar-collapsed > .sidebar {
  width: 68px !important;
}


body:not(.mobile-mode) #app-shell.sidebar-collapsed > .sidebar > * {
  visibility: visible !important;
  pointer-events: auto !important;
}

#app-shell > .sidebar {
  position: fixed !important;
  inset: 0 auto 0 0 !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 100dvh !important;
  height: 100dvh !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  overflow: visible !important;
  padding: 14px 12px 10px !important;
  gap: 0 !important;
  z-index: 40;
}

/* The fixed desktop rail is removed from grid flow, so keep the main panel in
   the second track and preserve the existing expanded/collapsed widths. */
body:not(.mobile-mode) #app-shell > .sidebar {
  width: 238px !important;
  max-height: 100dvh !important;
}

body:not(.mobile-mode) #app-shell > .main-panel {
  grid-column: 2 !important;
  min-width: 0 !important;
}

body:not(.mobile-mode) #app-shell.sidebar-collapsed > .sidebar {
  width: 68px !important;
}

#app-shell > .sidebar > .sidebar-top {
  flex: 0 0 auto;
  min-width: 0;
  display: grid;
  gap: 12px;
}

#app-shell > .sidebar .sidebar-controls {
  display: grid !important;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  width: 100%;
  min-width: 0;
  gap: 6px;
}

#app-shell > .sidebar .sidebar-controls .icon-btn,
#app-shell > .sidebar .language-switcher {
  min-width: 40px;
  min-height: 40px;
}

#app-shell > .sidebar .sidebar-controls .icon-btn {
  display: grid;
  place-items: center;
  padding: 0 !important;
  margin: 0 !important;
}

#app-shell > .sidebar .language-switcher {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  margin: 0;
  padding: 0 7px;
  border: 1px solid rgba(195, 145, 61, .28);
  border-radius: 8px;
  background: rgba(18, 22, 29, .62);
  color: var(--text-soft, #c7bdab);
}

#app-shell > .sidebar .language-switcher-icon {
  flex: 0 0 auto;
  font-size: 15px;
  line-height: 1;
}

#app-shell > .sidebar .language-switcher-label {
  flex: 0 0 auto;
  font-size: 11px;
  white-space: nowrap;
}

#app-shell > .sidebar .language-switcher select {
  min-width: 0;
  width: 100%;
  min-height: 32px;
  padding: 4px 20px 4px 0;
  border: 0;
  background: transparent;
  color: var(--text-main, #f7f1e4);
  font-size: 12px;
  outline: none;
}

#app-shell > .sidebar .sidebar-brand {
  min-width: 0;
  margin: 0;
  padding: 0 4px 8px;
}

#app-shell > .sidebar .sidebar-brand-mark {
  width: 42px;
  height: 42px;
}

#app-shell > .sidebar .sidebar-brand h2 {
  margin-top: 3px;
}

#app-shell > .sidebar .sidebar-nav {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  align-content: start;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 4px 0;
}

#app-shell > .sidebar .sidebar-nav .nav-item {
  min-height: 40px;
  touch-action: manipulation;
}

#app-shell > .sidebar .sidebar-nav .nav-item:focus-visible,
#app-shell > .sidebar .sidebar-controls button:focus-visible,
#app-shell > .sidebar .language-switcher:focus-within,
#app-shell > .sidebar .account-summary:focus-visible,
#app-shell > .sidebar .account-menu button:focus-visible {
  outline: 2px solid var(--accent, #d7a84c);
  outline-offset: 2px;
}

#app-shell > .sidebar .sidebar-footer {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 72px;
  padding: 8px 0 0 !important;
  border-top: 1px solid rgba(195, 145, 61, .18);
  background: transparent !important;
}

#app-shell > .sidebar .sidebar-account {
  position: relative;
  min-width: 0;
}

#app-shell > .sidebar .account-summary {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 58px;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid rgba(195, 145, 61, .25);
  border-radius: 9px;
  background: rgba(19, 26, 36, .82);
  color: var(--text-main, #f7f1e4);
  text-align: left;
  cursor: pointer;
}

#app-shell > .sidebar .account-avatar {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: rgba(215, 168, 76, .15);
  font-size: 16px;
}

#app-shell > .sidebar .account-summary-copy {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 2px;
}

#app-shell > .sidebar .account-summary .sidebar-user-name {
  overflow: hidden;
  color: var(--text-main, #f7f1e4);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell > .sidebar .account-summary-meta {
  overflow: hidden;
  color: var(--text-soft, #c7bdab);
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app-shell > .sidebar .account-device-indicator {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e16363;
  box-shadow: 0 0 0 3px rgba(225, 99, 99, .12);
}

#app-shell > .sidebar .account-device-indicator.is-authorized {
  background: #43d17b;
  box-shadow: 0 0 0 3px rgba(67, 209, 123, .12);
}

#app-shell > .sidebar .account-more {
  flex: 0 0 auto;
  color: var(--text-soft, #c7bdab);
  font-size: 18px;
  line-height: 1;
}

#app-shell > .sidebar .account-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 90;
  display: grid;
  gap: 10px;
  max-height: min(520px, calc(100dvh - 24px));
  overflow-y: auto;
  padding: 12px;
  border: 1px solid rgba(195, 145, 61, .4);
  border-radius: 10px;
  background: #151a22;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .38);
}

#app-shell > .sidebar .account-menu[hidden] {
  display: none;
}

#app-shell > .sidebar .account-menu-section,
#app-shell > .sidebar .account-menu-auth {
  display: grid;
  min-width: 0;
  gap: 7px;
}

#app-shell > .sidebar .account-menu-plan > div,
#app-shell > .sidebar .account-device-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-width: 0;
  gap: 12px;
}

#app-shell > .sidebar .account-menu-label {
  flex: 0 0 auto;
  color: var(--text-muted, #9eabc0);
  font-size: 11px;
}

#app-shell > .sidebar .account-menu strong,
#app-shell > .sidebar .account-menu .sidebar-user-email,
#app-shell > .sidebar .account-menu .sidebar-user-device {
  min-width: 0;
  color: var(--text-main, #f7f1e4);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-align: right;
}

#app-shell > .sidebar .account-menu .sidebar-user-email {
  text-align: left;
}

#app-shell > .sidebar .account-menu .sidebar-user-device {
  font-weight: 650;
}

#app-shell > .sidebar .account-menu .sidebar-user-device.is-unauthorized {
  color: #ef9a9a;
}

#app-shell > .sidebar .account-menu .sidebar-user-device.is-authorized {
  color: #7ee2a4;
}

#app-shell > .sidebar .account-menu-divider {
  height: 1px;
  background: rgba(195, 145, 61, .22);
}

#app-shell > .sidebar .account-menu-info {
  display: block;
  padding: 7px 0;
  color: var(--text-main, #f7f1e4);
  font-size: 12px;
}

#app-shell > .sidebar .account-menu .sidebar-member-btn {
  min-height: 36px !important;
  padding: 8px 10px !important;
  border-radius: 7px;
  font-size: 12px !important;
}

#app-shell > .sidebar .account-menu .sidebar-renewal-alert {
  margin: 0;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
}

#app-shell > .sidebar.sidebar.collapsed .sidebar-controls {
  grid-template-columns: 40px;
  grid-template-rows: repeat(3, 40px);
  justify-content: center;
  justify-items: center;
}

#app-shell > .sidebar.sidebar.collapsed .language-switcher {
  position: relative;
  display: grid;
  width: 40px;
  padding: 0;
  place-items: center;
  border-color: transparent;
  background: transparent;
}

#app-shell > .sidebar.sidebar.collapsed .language-switcher-label {
  display: none;
}

#app-shell > .sidebar.sidebar.collapsed .language-switcher select {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

#app-shell > .sidebar.sidebar.collapsed .language-switcher-icon {
  font-size: 17px;
}

#app-shell > .sidebar.sidebar.collapsed .sidebar-brand {
  display: grid;
  justify-items: center;
  padding: 0 0 8px;
}

#app-shell > .sidebar.sidebar.collapsed .sidebar-brand-mark {
  width: 38px;
  height: 38px;
}

#app-shell > .sidebar.sidebar.collapsed .sidebar-kicker,
#app-shell > .sidebar.sidebar.collapsed .sidebar-brand h2,
#app-shell > .sidebar.sidebar.collapsed .account-summary-copy,
#app-shell > .sidebar.sidebar.collapsed .account-more {
  display: none;
}

#app-shell > .sidebar.sidebar.collapsed .sidebar-nav .nav-group-label,
#app-shell > .sidebar.sidebar.collapsed .sidebar-nav .ui-label {
  display: none;
}

#app-shell > .sidebar.sidebar.collapsed .sidebar-nav .nav-item {
  justify-content: center;
  min-height: 40px;
  padding: 8px;
}

#app-shell > .sidebar.sidebar.collapsed .sidebar-nav .ui-icon {
  margin: 0;
}

#app-shell > .sidebar.sidebar.collapsed .account-summary {
  justify-content: center;
  min-height: 54px;
  padding: 7px 4px;
}

#app-shell > .sidebar.sidebar.collapsed .account-device-indicator {
  position: absolute;
  right: 5px;
  bottom: 10px;
  width: 6px;
  height: 6px;
}

#app-shell > .sidebar.sidebar.collapsed .account-menu {
  right: auto;
  left: calc(100% + 8px);
  width: 220px;
}

.view-panel {
  min-width: 0;
  padding-top: 0 !important;
}

.view-action-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 40px;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.view-action-bar .view-action-spacer {
  flex: 1 1 auto;
  min-width: 0;
}

.view-action-bar .customer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.view-action-bar .customer-actions > :is(button, a) {
  min-height: 38px;
}

.compact-safety-note {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-left: 2px solid rgba(215, 168, 76, .62);
  color: var(--text-soft, #c7bdab);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 980px) {
  html body.mobile-mode #app-shell > .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    display: flex !important;
    width: min(320px, calc(100vw - 40px)) !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-width: none !important;
    overflow: hidden !important;
    padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom)) !important;
    gap: 16px !important;
    transform: translateX(-102%) !important;
    z-index: 84 !important;
  }

  html body.mobile-mode.mobile-nav-open #app-shell > .sidebar {
    transform: translateX(0) !important;
  }

  html body.mobile-mode #app-shell > .sidebar,
  html body.mobile-mode .sidebar-mobile-backdrop {
    transition: none !important;
  }

  #app-shell > .sidebar {
    width: min(320px, 86vw) !important;
  }

  html body.mobile-mode #app-shell > .sidebar .sidebar-nav {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  html body.mobile-mode #app-shell > .sidebar .sidebar-footer {
    flex: 0 0 auto !important;
    display: block !important;
  }

  #app-shell > .sidebar .sidebar-nav {
    overflow-y: auto !important;
  }

  body.mobile-mode #app-shell > .sidebar .sidebar-brand,
  body.mobile-mode #app-shell > .sidebar .sidebar-footer {
    display: block !important;
  }

  body.mobile-mode #app-shell > .sidebar .account-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    left: 0;
    width: auto;
  }

  body.mobile-mode #app-shell > .sidebar .view-action-bar {
    min-height: 40px;
  }

  .view-action-bar .customer-actions {
    width: 100%;
    justify-content: stretch;
  }

  .view-action-bar .customer-actions > :is(button, a) {
    flex: 1 1 auto;
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .view-action-bar {
    align-items: stretch;
  }

  .view-action-bar .customer-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  #app-shell > .sidebar,
  #app-shell > .sidebar-mobile-backdrop {
    transition: none !important;
  }
}

/* Compact language control: the native select remains the single direct
   selection surface while the closed control keeps stable 44px geometry. */
#app-shell > .sidebar .sidebar-controls {
  grid-template-columns: 40px 44px 40px;
  column-gap: 8px;
}

#app-shell > .sidebar .language-switcher {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  gap: 4px;
  padding: 0;
}

#app-shell > .sidebar .language-switcher-label {
  display: inline-grid;
  width: 20px;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}

#app-shell > .sidebar .language-switcher select {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 44px;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  appearance: none;
}

#app-shell > .sidebar.sidebar.collapsed .sidebar-controls {
  grid-template-columns: 40px;
  gap: 8px;
}

#app-shell > .sidebar.sidebar.collapsed .language-switcher {
  flex-basis: 40px;
  width: 40px;
  min-width: 40px;
}

/* Responsive P0 authority: one control owner, one live drawer boundary. */
#app-shell > .sidebar-controls {
  position: fixed;
  top: 14px;
  left: 12px;
  z-index: 100;
  display: grid;
  grid-template-columns: 40px 44px 40px;
  align-items: center;
  width: 214px;
  min-width: 0;
  gap: 8px;
}

#app-shell > .sidebar-controls .icon-btn,
#app-shell > .sidebar-controls .language-switcher {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
}

#app-shell > .sidebar-controls .icon-btn {
  display: grid;
  place-items: center;
  padding: 0 !important;
  margin: 0 !important;
}

#app-shell > .sidebar-controls .language-switcher {
  position: relative;
  display: flex;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
}

#app-shell > .sidebar-controls .language-switcher select {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 44px;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

@media (min-width: 1024px) {
  body:not(.mobile-mode) #app-shell {
    grid-template-columns: 238px minmax(0, 1fr) !important;
  }

  body:not(.mobile-mode) #app-shell > .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    width: 238px !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 72px 12px 10px !important;
  }

  body:not(.mobile-mode) #app-shell.sidebar-collapsed {
    grid-template-columns: 68px minmax(0, 1fr) !important;
  }

  body:not(.mobile-mode) #app-shell.sidebar-collapsed > .sidebar {
    width: 68px !important;
    padding: 72px 8px 10px !important;
  }

  body:not(.mobile-mode) #app-shell.sidebar-collapsed > .sidebar-controls {
    left: 12px;
    width: 44px;
    grid-template-columns: 44px;
    grid-template-rows: repeat(3, 40px);
    gap: 8px;
  }

  body:not(.mobile-mode) #app-shell.sidebar-collapsed > .sidebar-controls .language-switcher {
    width: 40px;
    min-width: 40px;
  }
}

@media (max-width: 1023px) {
  #app-shell,
  #app-shell.sidebar-collapsed {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  #app-shell > .sidebar-controls {
    position: fixed !important;
    top: max(12px, env(safe-area-inset-top)) !important;
    left: max(12px, env(safe-area-inset-left)) !important;
    width: 214px !important;
    grid-template-columns: 40px 44px 40px;
  }

  #app-shell > .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: 84 !important;
    display: flex !important;
    width: min(320px, calc(100vw - 40px)) !important;
    max-width: none !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    padding: 74px 14px max(18px, env(safe-area-inset-bottom)) !important;
    overflow: hidden !important;
    transform: translateX(-102%) !important;
  }

  body.mobile-nav-open #app-shell > .sidebar {
    transform: translateX(0) !important;
  }

  body.mobile-mode #app-shell > .main-panel {
    grid-column: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    /* Keep the first compact view content below the fixed global controls.
       This is clearance only; no page header or extra content block returns. */
    padding-top: calc(max(12px, env(safe-area-inset-top)) + 50px + 12px) !important;
    overflow-x: clip !important;
  }

  #app-shell > .sidebar .sidebar-top,
  #app-shell > .sidebar .sidebar-brand,
  #app-shell > .sidebar .sidebar-footer {
    flex: 0 0 auto !important;
  }

  #app-shell > .sidebar .sidebar-nav {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  #app-shell > .sidebar .sidebar-brand,
  #app-shell > .sidebar .sidebar-footer {
    display: block !important;
  }
}

/* The former max-900 automatic icon rail is intentionally neutralized. */
@media (min-width: 760px) and (max-width: 1023px) {
  body:not(.mobile-mode) #app-shell {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body:not(.mobile-mode) #app-shell > .sidebar {
    display: flex !important;
    width: min(320px, calc(100vw - 40px)) !important;
  }

  body:not(.mobile-mode) #app-shell > .sidebar .ui-label,
  body:not(.mobile-mode) #app-shell > .sidebar .sidebar-brand,
  body:not(.mobile-mode) #app-shell > .sidebar .sidebar-footer {
    display: block !important;
  }
}

/* Comment console reflow: keep the page width stable and let owned rows wrap. */
#comments-view,
#comments-view .comments-health-strip,
#comments-view .keyword-order-card,
#comments-view .comment-workspace-card,
#comments-view .comment-list,
#comments-view .comment-row,
#comments-view .comment-body {
  min-width: 0;
  max-width: 100%;
}

#comments-view .comments-health-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

#comments-view .comments-health-card {
  min-width: min(220px, 100%);
  flex: 1 1 220px;
}

#comments-view .platform-filter-row {
  min-width: 0;
  max-width: 100%;
}

#comments-view .platform-filters {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

#comments-view .keyword-order-main-row,
#comments-view .keyword-order-device-row,
#comments-view .keyword-order-device-controls,
#comments-view .keyword-order-action-row {
  min-width: 0;
}

@media (max-width: 1023px) {
  #comments-view .keyword-order-main-row,
  #comments-view .keyword-order-device-row,
  #comments-view .keyword-order-action-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #comments-view .keyword-order-capacity,
  #comments-view .keyword-order-primary,
  #comments-view .keyword-order-actions {
    grid-column: 1 / -1;
  }

  #comments-view .keyword-order-device-controls {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #comments-view .keyword-order-device-controls > * {
    min-width: 0;
    width: 100%;
  }

  #comments-view .keyword-order-actions {
    display: flex;
    flex-wrap: wrap;
  }

  #comments-view .keyword-order-actions > * {
    flex: 1 1 150px;
    min-width: 0;
  }

  #comments-view .comment-row {
    grid-template-columns: minmax(0, 1fr) auto !important;
  }

  #comments-view .comment-row .comment-body {
    overflow-wrap: anywhere;
  }
}
