/* Quantum Black — App Shell (Phase 1) · platform-ui-spec.md */

@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Syne:wght@600;700&display=swap");
@import url("https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/style.min.css");

html {
  overflow-x: hidden;
  max-width: 100%;
}

body.qb-platform {
  overflow-x: hidden;
  max-width: 100vw;
}

:root {
  --font-display: "Syne", "Helvetica Neue", sans-serif;
  --font-body: "Geist", "SF Pro Text", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;

  --shell-bg: #070708;
  --shell-sidebar: #0a0b0d;
  --shell-topbar: #0e0f11;
  --shell-border: rgba(255, 255, 255, 0.06);

  --nav-item-height: var(--touch-target-min, 44px);
  --nav-item-active-bg: rgba(0, 229, 160, 0.1);
  --nav-item-active-border: #00e5a0;
  --nav-group-label: #6b7080;

  --severity-low: #6b7080;
  --severity-medium: #fbbf24;
  --severity-high: #fb923c;
  --severity-critical: #f87171;

  --trend-up: #34d399;
  --trend-down: #f87171;
  --trend-flat: #6b7080;

  --status-live: #34d399;
  --status-sync: #fbbf24;
  --status-error: #f87171;

  --qb-accent: #00e5a0;
  --qb-accent-subtle: rgba(0, 229, 160, 0.12);
  --qb-accent-glow: rgba(0, 229, 160, 0.35);
}

html[data-theme="dark"] .qb-shell,
.qb-shell {
  --ink: #f2f3f5;
  --text: #dbe5f1;
  --muted: #6b7080;
  --line: rgba(255, 255, 255, 0.08);
  --paper: #0e0f11;
  --wash: #141518;
  --soft-panel: #141518;
  --hover: #1a1b1f;
  --blue: #00e5a0;
  --blue-soft: rgba(0, 229, 160, 0.12);
  --sidebar: var(--shell-sidebar);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] .qb-shell {
  --shell-bg: #f4f7fb;
  --shell-sidebar: #111827;
  --shell-topbar: #111827;
  --shell-border: rgba(255, 255, 255, 0.08);
  --ink: #111827;
  --text: #172033;
  --muted: #657386;
  --line: #d9e1ec;
  --paper: #ffffff;
  --wash: #f4f7fb;
  --soft-panel: #fbfdff;
  --hover: #f5faff;
}

.qb-shell {
  font-family: var(--font-body);
  background: var(--shell-bg);
  color: var(--ink);
}

.auth-panel .brand-mark.qb-brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 10px;
  background: var(--qb-accent-subtle);
  color: var(--qb-accent);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.auth-panel .auth-brand-lead {
  margin-top: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ── Auth gate (Phase D) ── */
.qb-platform .auth-gate:not(.hidden) {
  position: fixed;
  inset: 0;
  display: grid !important;
  place-items: center;
  padding: 20px;
  background: var(--shell-bg, #070708);
  z-index: 2000;
}

.qb-platform .auth-gate {
  background: var(--shell-bg, #070708);
  z-index: 1000;
}

.qb-platform .auth-panel {
  width: min(400px, 100%);
  padding: 28px 24px 24px;
  border: 1px solid var(--shell-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 8px);
  background: var(--paper, #0e0f11);
  box-shadow: none;
  color: var(--ink);
}

.qb-platform .auth-panel h1 {
  margin: 12px 0 4px;
  font-family: var(--font-display);
  font-size: 24px;
  text-align: center;
  letter-spacing: -0.02em;
}

.qb-platform .auth-lead {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.qb-platform .auth-steps {
  display: none;
}

.qb-platform .auth-theme-switch button {
  min-height: 32px;
  min-width: 44px;
}

.qb-platform .auth-theme-switch button.active {
  color: #070708;
  border-color: var(--qb-accent);
  background: var(--qb-accent);
}

.qb-platform .auth-form label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.qb-platform .auth-form input {
  min-height: var(--touch-target-min, 44px);
  border-color: var(--line);
  background: var(--soft-panel);
  color: var(--ink);
}

.qb-platform .auth-form input:focus-visible {
  outline: 2px solid var(--qb-accent);
  outline-offset: 2px;
  border-color: var(--qb-accent);
}

.qb-platform .auth-form .primary-button {
  min-height: var(--touch-target-min, 44px);
  margin-top: 4px;
}

.qb-platform .toolbar input:focus-visible,
.qb-platform .toolbar select:focus-visible,
.qb-platform .editor-form input:focus-visible,
.qb-platform .editor-form select:focus-visible,
.qb-platform .editor-form textarea:focus-visible {
  outline: 2px solid var(--qb-accent);
  outline-offset: 2px;
  border-color: var(--qb-accent);
}

.qb-shell h1 {
  font-family: var(--font-display);
  font-weight: 700;
}

.qb-shell #statusLine,
.qb-shell .sync-state,
.qb-shell .global-search-kbd {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── Quantum Black app shell ── */
html {
  overflow-x: hidden;
  max-width: 100%;
}

body.qb-platform {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ── Top bar 48px ── */
.qb-topbar {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 48px;
  padding: 0 12px 0 8px;
  background: var(--shell-topbar);
  border-bottom: 1px solid var(--shell-border);
}

.qb-topbar-start,
.qb-topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.qb-topbar-end {
  flex-shrink: 0;
}

.qb-nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #f2f3f5;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.qb-nav-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

.qb-nav-toggle:focus-visible {
  outline: 2px solid var(--qb-accent);
  outline-offset: 2px;
}

.qb-nav-backdrop {
  display: none;
  position: fixed;
  inset: 48px 0 0;
  z-index: 114;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.qb-nav-backdrop[hidden] {
  display: none !important;
}

body.qb-nav-open .qb-nav-backdrop:not([hidden]) {
  display: block;
}

.qb-sidebar-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #f2f3f5;
  font-size: 18px;
  cursor: pointer;
}

.qb-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

.qb-sidebar-toggle:focus-visible {
  outline: 2px solid var(--qb-accent);
  outline-offset: 2px;
}

.qb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.qb-brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--qb-accent-subtle);
  color: var(--qb-accent);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.qb-brand .brand-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: #f2f3f5;
  line-height: 1.15;
}

.qb-brand .brand-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--nav-group-label);
}

.qb-brand-text {
  min-width: 0;
}

.qb-topbar .club-picker-inline select {
  height: 32px;
  font-size: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--shell-border);
  color: #f2f3f5;
}

.qb-topbar-center {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
  max-width: 420px;
  margin: 0 auto;
}

.qb-topbar .global-search-wrap {
  width: 100%;
  position: relative;
}

.qb-topbar .global-search {
  width: 100%;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--shell-border);
  background: rgba(255, 255, 255, 0.04);
  color: #f2f3f5;
}

.qb-topbar .global-search input {
  color: inherit;
}

.qb-topbar .global-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 200;
}

.qb-command-btn {
  display: none;
}

.qb-topbar .sync-box-inline {
  padding: 0;
  background: transparent;
  border: none;
}

.qb-topbar .sync-state {
  color: #a8acb8;
  font-size: 11px;
  white-space: nowrap;
}

.qb-topbar .sync-dot {
  width: 8px;
  height: 8px;
}

.qb-account {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qb-user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 8px 4px 4px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: default;
}

.qb-user-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--qb-accent-subtle);
  color: var(--qb-accent);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.qb-user-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
  text-align: left;
}

.qb-user-meta .user-name {
  font-size: 13px;
  font-weight: 600;
  color: #f2f3f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.qb-role-badge {
  font-size: 11px;
  color: var(--nav-group-label);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.qb-topbar .role-preview-switch button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--shell-border);
  background: rgba(255, 255, 255, 0.04);
  color: #a8acb8;
  font-size: 11px;
  cursor: pointer;
}

.qb-topbar .role-preview-switch button.active {
  border-color: var(--qb-accent);
  color: var(--qb-accent);
  background: var(--qb-accent-subtle);
}

.qb-app-header .qb-topbar-end,
.qb-app-header .qb-account,
.qb-app-header .role-preview-switch {
  position: relative;
  z-index: 5;
}

.qb-app-header .role-preview-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 0;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.qb-app-header .role-preview-switch button {
  position: relative;
  z-index: 6;
  pointer-events: auto;
  cursor: pointer;
  min-width: 0;
  white-space: nowrap;
}

.qb-topbar .user-logout {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--shell-border);
  background: transparent;
  color: #a8acb8;
  font-size: 12px;
  cursor: pointer;
}

.qb-topbar .user-logout:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f2f3f5;
}

/* ── Layout ── */
.qb-layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 48px);
  min-width: 0;
}

.qb-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--shell-sidebar);
  border-right: 1px solid var(--shell-border);
  overflow-y: auto;
  position: sticky;
  top: 48px;
  height: calc(100vh - 48px);
}

.qb-sidebar-backdrop {
  display: none;
}

.qb-main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.qb-main-wrap > .main {
  flex: 1;
  background: #f4f7fb;
}

/* ── Sidebar nav ── */
.qb-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 24px;
  width: 100%;
  min-height: auto;
  overflow: visible;
}

.qb-sidebar-nav .nav-group {
  position: static;
  flex: none;
}

.qb-sidebar-nav .nav-group > summary {
  min-height: var(--touch-target-min, 44px);
  padding: 10px 12px 6px;
  border-radius: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nav-group-label);
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.qb-sidebar-nav .nav-group > summary:hover {
  color: #a8acb8;
  background: rgba(255, 255, 255, 0.04);
}

.qb-sidebar-nav .nav-group > summary::-webkit-details-marker {
  display: none;
}

.qb-sidebar-nav .nav-group > summary::after {
  display: inline-block;
  margin-left: 6px;
  content: "▾";
  font-size: 9px;
  opacity: 0.45;
  transition: transform 150ms ease-out;
}

.qb-sidebar-nav .nav-group:not([open]) > summary::after {
  transform: rotate(-90deg);
}

.qb-sidebar-nav .nav-group[open] > summary,
.qb-sidebar-nav .nav-group.has-active > summary {
  color: #a8acb8;
  background: transparent;
}

.qb-sidebar-nav .nav-group-menu {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  margin: 0;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.qb-sidebar-nav .nav-analytics-menu,
.qb-sidebar-nav .nav-finance-menu {
  gap: 2px;
}

.qb-sidebar-nav .nav-analytics-primary,
.qb-sidebar-nav .nav-finance-primary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  grid-template-columns: none;
}

.qb-sidebar-nav .nav-sub-group {
  border: none;
  background: transparent;
  margin-left: 8px;
}

.qb-sidebar-nav .nav-sub-group > summary {
  min-height: var(--touch-target-min, 44px);
  padding: 6px 10px;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--nav-group-label);
  pointer-events: auto;
  cursor: pointer;
  border-radius: 6px;
}

.qb-sidebar-nav .nav-sub-group > summary:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #a8acb8;
}

.qb-sidebar-nav .nav-sub-group-menu {
  padding: 0 0 4px 8px;
}

.qb-sidebar-nav .tab.tab-sub {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--nav-item-height);
  margin: 0;
  padding: 0 12px;
  border: none;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: #a8acb8;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}

.qb-sidebar-nav .tab.tab-sub:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #f2f3f5;
}

.qb-sidebar-nav .tab.tab-sub.active,
.qb-sidebar-nav .tab.tab-sub[aria-current="page"] {
  background: var(--nav-item-active-bg);
  border-left-color: var(--nav-item-active-border);
  color: #f2f3f5;
  font-weight: 500;
}

.qb-sidebar-nav .tab.tab-sub:focus-visible {
  outline: 2px solid var(--qb-accent);
  outline-offset: -2px;
}

.qb-sidebar-nav .nav-group-finance > summary,
.qb-sidebar-nav .nav-group-settings > summary,
.qb-sidebar-nav .nav-group-archive > summary {
  opacity: 0.75;
}

.qb-shell .topbar {
  min-height: auto;
  padding-top: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.qb-shell .topbar h1 {
  font-size: 28px;
  line-height: 1.15;
}

.qb-shell .topbar .top-actions {
  align-items: center;
}

.qb-shell .topbar .global-search-wrap {
  display: none;
}

.qb-shell .theme-switch {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.qb-shell .theme-switch button {
  min-height: 36px;
  min-width: 44px;
}

@keyframes qb-live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.qb-topbar .sync-dot:not(.loading):not(.offline) {
  background: var(--status-live);
  animation: qb-live-pulse 2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .qb-topbar .sync-dot {
    animation: none;
  }

  .qb-sidebar-nav .tab.tab-sub {
    transition: none;
  }
}

@media (max-width: 767px) {
  .qb-sidebar-toggle {
    display: grid;
    place-items: center;
  }

  .qb-topbar-center {
    display: none;
  }

  .qb-command-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--shell-border);
    background: rgba(255, 255, 255, 0.04);
    color: #a8acb8;
    font-size: 13px;
    cursor: pointer;
  }

  .qb-command-btn kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    opacity: 0.7;
  }

  .qb-sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    z-index: 110;
    height: calc(100vh - 48px);
    transform: translateX(-100%);
    transition: transform 220ms ease-out;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
  }

  body.qb-sidebar-open .qb-sidebar {
    transform: translateX(0);
  }

  .qb-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 48px 0 0;
    z-index: 105;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    padding: 0;
    cursor: pointer;
  }

  .qb-sidebar-backdrop[hidden] {
    display: none !important;
  }

  .qb-user-meta {
    display: none;
  }

  .qb-topbar .club-picker-inline {
    display: none;
  }
}

@media (min-width: 1280px) {
  .qb-main-wrap > .main {
    padding: 20px 28px 48px;
  }
}

/* ── Owner home · 5 quick actions ── */
.qb-shell .quick-actions-panel.owner-home {
  border-color: var(--shell-border);
  border-radius: var(--radius-lg, 8px);
  background: var(--paper);
  box-shadow: none;
}

.qb-shell .quick-actions-panel.owner-home h2 {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.02em;
}

.qb-shell .quick-action {
  min-height: var(--touch-target-min, 44px);
  border-radius: var(--radius-lg, 8px);
  transition: border-color var(--duration-fast, 150ms) ease-out, background var(--duration-fast, 150ms) ease-out;
}

.qb-shell .quick-action:hover {
  border-color: var(--qb-accent);
  background: var(--qb-accent-subtle);
}

.qb-shell .quick-action:focus-visible {
  outline: 2px solid var(--qb-accent);
  outline-offset: 2px;
}

.qb-shell .quick-action.good {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}

.qb-shell .quick-action.warn {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}

/* ── KPI visual pass (Quantum Black tokens) ── */
.qb-shell .owner-kpi-simple {
  border-color: var(--shell-border);
  background: var(--paper);
  box-shadow: none;
}

.qb-shell .owner-kpi-card {
  border-radius: var(--radius-lg, 8px);
  box-shadow: none;
  border-color: var(--line);
}

.qb-shell .owner-kpi-card.good {
  border-top: 3px solid var(--trend-up, #34d399);
}

.qb-shell .owner-kpi-card.warn {
  border-top: 3px solid var(--severity-medium, #fbbf24);
}

.qb-shell .owner-kpi-card.bad {
  border-top: 3px solid var(--trend-down, #f87171);
}

.qb-shell .owner-kpi-card strong,
.qb-shell .qb-metric-card__ours,
.qb-shell .qb-metric-card__meta dd {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.qb-shell .qb-metric-card--adjusted {
  border-color: color-mix(in srgb, var(--qb-accent) 50%, var(--line));
}

.qb-shell .metric-adjust-card,
.qb-shell .training-role-ladder__item {
  background: var(--paper);
  border-color: var(--line);
}

.qb-shell .kpi-scoreboard {
  border-radius: var(--radius-lg, 8px);
  background: var(--paper);
  box-shadow: none;
  border-color: var(--line);
}

.qb-shell .kpi-score-value {
  border-color: var(--kpi-accent, var(--qb-accent));
  font-family: var(--font-mono);
}

.qb-shell #view-overview .metric {
  box-shadow: none;
  border-radius: var(--radius-lg, 8px);
}

.qb-shell #view-overview .metric.good {
  border-top-color: var(--trend-up, #34d399);
}

.qb-shell #view-overview .metric.warn {
  border-top-color: var(--severity-medium, #fbbf24);
}

.qb-shell #view-overview .metric.bad {
  border-top-color: var(--trend-down, #f87171);
}

.qb-shell #view-overview .metric-value {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ── Quantum Black shell layout (left / right / top / bottom) ── */
.qb-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.qb-app-header {
  position: sticky;
  top: 0;
  z-index: 300;
  isolation: isolate;
  flex-shrink: 0;
  background: var(--shell-topbar, #0e0f11);
  border-bottom: 1px solid var(--shell-border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
}

.qb-app-header .app-header-top.qb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: auto;
  min-height: 52px;
  padding: 6px 12px;
  border-bottom: none;
  position: relative;
  z-index: 3;
  top: auto;
  background: var(--shell-topbar, #0e0f11);
  overflow: visible;
  flex-wrap: nowrap;
}

.qb-app-header .qb-topbar-end,
.qb-app-header .qb-account,
.qb-app-header .user-panel {
  flex-wrap: nowrap;
  align-items: center;
  flex-shrink: 0;
}

.qb-app-header .qb-topbar-start,
.qb-app-header .qb-topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.qb-app-header .qb-topbar-end {
  flex-shrink: 0;
}

.qb-app-header .qb-topbar-center {
  flex: 1 1 auto;
  max-width: 420px;
  min-width: 0;
}

.qb-shell-edge-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.qb-shell-edge-switch button {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #a8acb8;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.qb-shell-edge-switch button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f2f3f5;
}

.qb-shell-edge-switch button.is-active {
  background: var(--qb-accent-subtle);
  color: var(--qb-accent);
}

.qb-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

.qb-shell-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 240px;
  flex-shrink: 0;
  padding: 8px 8px 24px;
  background: var(--shell-sidebar);
  border-right: 1px solid var(--shell-border);
  overflow-x: hidden;
  overflow-y: auto;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  align-self: flex-start;
  z-index: 80;
}

/* Override legacy .tabs { flex-row } from styles.css */
.qb-shell-nav.tabs {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
}

.qb-main-wrap {
  flex: 1;
  min-width: 0;
  width: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.qb-main-wrap > .main {
  flex: 1;
  background: #f4f7fb;
  min-width: 0;
}

body[data-nav-edge="right"] .qb-layout {
  flex-direction: row-reverse;
}

body[data-nav-edge="right"] .qb-shell-nav {
  border-right: none;
  border-left: 1px solid var(--shell-border);
}

body[data-nav-edge="top"] .qb-layout,
body[data-nav-edge="bottom"] .qb-layout {
  flex-direction: column;
}

body[data-nav-edge="bottom"] .qb-layout {
  flex-direction: column-reverse;
}

body[data-nav-edge="top"] .qb-shell-nav,
body[data-nav-edge="bottom"] .qb-shell-nav {
  width: 100%;
  height: auto;
  max-height: none;
  position: relative;
  top: auto;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 8px;
  padding: 8px 12px;
  border-right: none;
  border-bottom: 1px solid var(--shell-border);
  overflow: visible;
}

body[data-nav-edge="bottom"] .qb-shell-nav {
  border-bottom: none;
  border-top: 1px solid var(--shell-border);
}

body[data-nav-edge="top"] .qb-shell-nav .nav-group,
body[data-nav-edge="bottom"] .qb-shell-nav .nav-group {
  position: relative;
  flex: 0 0 auto;
}

body[data-nav-edge="top"] .qb-shell-nav .nav-group > summary,
body[data-nav-edge="bottom"] .qb-shell-nav .nav-group > summary {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.78);
}

body[data-nav-edge="top"] .qb-shell-nav .nav-group-menu,
body[data-nav-edge="bottom"] .qb-shell-nav .nav-group-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 230;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--shell-border);
  border-radius: 8px;
  background: var(--shell-sidebar, #0a0b0d);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  display: none;
}

body[data-nav-edge="bottom"] .qb-shell-nav .nav-group-menu {
  top: auto;
  bottom: calc(100% + 4px);
}

body[data-nav-edge="top"] .qb-shell-nav .nav-group[open] > .nav-group-menu,
body[data-nav-edge="bottom"] .qb-shell-nav .nav-group[open] > .nav-group-menu {
  display: flex;
}

body[data-nav-edge="top"] .qb-shell-nav .nav-analytics-primary,
body[data-nav-edge="top"] .qb-shell-nav .nav-finance-primary,
body[data-nav-edge="bottom"] .qb-shell-nav .nav-analytics-primary,
body[data-nav-edge="bottom"] .qb-shell-nav .nav-finance-primary {
  display: flex;
  flex-direction: column;
}

body[data-nav-edge="top"] .qb-shell-nav .tab.tab-sub,
body[data-nav-edge="bottom"] .qb-shell-nav .tab.tab-sub {
  border-left: none;
  border-radius: 6px;
}

body[data-nav-edge="top"] .qb-shell-nav .tab.tab-sub.active,
body[data-nav-edge="bottom"] .qb-shell-nav .tab.tab-sub.active {
  box-shadow: inset 2px 0 0 var(--nav-item-active-border);
  border-left: none;
}

.qb-shell-prefs {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.qb-shell-pref-group {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
}

.qb-shell-pref-group legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #6b7080);
}

.qb-shell-pref-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qb-shell-pref-options .secondary-button.is-active {
  border-color: var(--qb-accent, #00e5a0);
  color: var(--qb-accent, #00e5a0);
  background: var(--qb-accent-subtle, rgba(0, 229, 160, 0.12));
}

/* Legacy sidebar chrome stays off — nav now lives in .qb-shell-nav */
.qb-sidebar,
.qb-sidebar-backdrop,
.qb-sidebar-toggle {
  display: none !important;
}

@media (max-width: 767px) {
  .qb-command-btn {
    display: inline-flex;
  }

  .qb-shell-edge-switch {
    display: none;
  }
}

/* Mobile / tablet drawer — must stay last */
@media (max-width: 1024px) {
  .qb-nav-toggle {
    display: grid;
    place-items: center;
  }

  .qb-app-header .qb-topbar-center {
    display: none;
  }

  .qb-app-header .app-header-top.qb-topbar {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 4px 8px;
    min-height: 48px;
  }

  .qb-topbar-start {
    flex: 1 1 auto;
    min-width: 0;
  }

  .qb-brand .brand-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 42vw;
  }

  .qb-topbar .club-picker-inline {
    display: none;
  }

  body[data-nav-edge] .qb-shell-nav,
  .qb-shell-nav {
    position: fixed !important;
    top: 48px !important;
    left: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    z-index: 116;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch;
    gap: 4px;
    width: min(320px, 92vw) !important;
    height: auto !important;
    max-height: none !important;
    margin: 0;
    padding: 10px 8px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--shell-border) !important;
    border-left: none !important;
    border-top: none !important;
    border-bottom: none !important;
    background: var(--shell-sidebar, #0a0b0d);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
    transform: translateX(-105%);
    transition: transform 220ms ease-out;
    -webkit-overflow-scrolling: touch;
  }

  body.qb-nav-open .qb-shell-nav {
    transform: translateX(0);
  }

  .qb-shell-nav .nav-group {
    width: 100%;
    flex: 0 0 auto;
  }

  .qb-shell-nav .nav-group > summary {
    min-height: 44px;
    width: 100%;
  }

  .qb-shell-nav .nav-group-menu {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    z-index: auto;
    display: none;
    width: 100%;
    min-width: 0;
    margin-top: 2px;
    padding: 4px 0 6px 8px;
    border: none !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
  }

  .qb-shell-nav .nav-group[open] > .nav-group-menu {
    display: flex;
  }

  .qb-shell-nav .nav-analytics-primary,
  .qb-shell-nav .nav-finance-primary {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .qb-brand .brand-subtitle {
    display: none;
  }

  .section-term-guide,
  .section-term-guide__inner {
    max-width: 100%;
  }

  .section-term-guide__def,
  .section-term-guide__why {
    overflow-wrap: anywhere;
  }
}
