/*
 * Responsive shell for every non-home page.
 * The home dashboard keeps its production layout untouched; this file is
 * loaded only by internal React routes and the shared internal shell.
 */

html,
body {
  min-width: 320px;
  overflow-x: hidden;
}

body[data-react-page]:not([data-react-page="index"]) .app-shell,
body[data-react-page]:not([data-react-page="index"]) .site-header__inner,
body[data-react-page]:not([data-react-page="index"]) .xa-shell,
body[data-react-page]:not([data-react-page="index"]) .fx-shell,
body[data-react-page]:not([data-react-page="index"]) .pro-shell,
.app-shell[data-react-shell="production"] {
  max-width: 1440px;
  width: min(1440px, calc(100% - 48px));
  min-width: 0;
}

/* Keep the internal navigation usable while a page-specific data layer loads. */
body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar,
body[data-react-page]:not([data-react-page="index"]) .site-header__inner,
body[data-react-page]:not([data-react-page="index"]) .xa-topbar,
body[data-react-page]:not([data-react-page="index"]) .fx-topbar,
body[data-react-page]:not([data-react-page="index"]) .events-topbar,
body[data-react-page]:not([data-react-page="index"]) .pro-topbar,
.app-shell[data-react-shell="production"] > .topbar {
  position: relative;
  z-index: 60;
}

body[data-react-page]:not([data-react-page="index"]) main,
body[data-react-page]:not([data-react-page="index"]) section,
body[data-react-page]:not([data-react-page="index"]) article,
body[data-react-page]:not([data-react-page="index"]) .panel,
body[data-react-page]:not([data-react-page="index"]) .card,
.app-shell[data-react-shell="production"] main,
.app-shell[data-react-shell="production"] section,
.app-shell[data-react-shell="production"] article,
.app-shell[data-react-shell="production"] .panel {
  min-width: 0;
}

body[data-react-page]:not([data-react-page="index"]) img,
body[data-react-page]:not([data-react-page="index"]) svg,
body[data-react-page]:not([data-react-page="index"]) canvas,
.app-shell[data-react-shell="production"] img,
.app-shell[data-react-shell="production"] svg,
.app-shell[data-react-shell="production"] canvas {
  max-width: 100%;
}

/* Generic internal header: compact on desktop and predictable on tablets. */
body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) {
  display: grid;
  grid-template-columns: minmax(150px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(14px, 2.6vw, 34px);
  min-height: 76px;
  padding: 10px 0;
}

body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .main-nav {
  min-width: 0;
  justify-content: center;
  flex-wrap: wrap;
}

body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .topbar__actions {
  min-width: 0;
  justify-content: flex-end;
}

body[data-react-page]:not([data-react-page="index"]) .mobile-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid rgba(85, 214, 239, .25);
  border-radius: 11px;
  background: rgba(85, 214, 239, .07);
  color: #d9f8ff;
  font: inherit;
  font-size: .68rem;
  font-weight: 800;
  cursor: pointer;
}

body[data-react-page]:not([data-react-page="index"]) .mobile-nav-toggle:hover,
body[data-react-page]:not([data-react-page="index"]) .mobile-nav-toggle[aria-expanded="true"] {
  border-color: rgba(85, 214, 239, .55);
  background: rgba(85, 214, 239, .14);
  color: #fff;
}

/* Tables and long technical rows must scroll inside their own panel. */
body[data-react-page]:not([data-react-page="index"]) table {
  max-width: 100%;
}

body[data-react-page]:not([data-react-page="index"]) pre,
body[data-react-page]:not([data-react-page="index"]) .table-wrap,
body[data-react-page]:not([data-react-page="index"]) .table-scroll,
body[data-react-page]:not([data-react-page="index"]) .data-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

/* Login is deliberately calmer and narrower than the data-heavy pages. */
body.auth-page .app-shell {
  width: min(1220px, calc(100% - 48px));
}

body.auth-page .topbar {
  min-height: 70px;
  border-bottom: 1px solid rgba(157, 185, 219, .15);
}

body.auth-page .auth-layout {
  grid-template-columns: minmax(0, 1fr) minmax(350px, 470px);
  gap: clamp(36px, 7vw, 104px);
}

body.auth-page .auth-intro,
body.auth-page .auth-card {
  min-width: 0;
}

body.auth-page .auth-card {
  width: 100%;
}

@media (max-width: 1120px) {
  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) {
    gap: 14px;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .main-nav {
    gap: 2px;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .main-nav a {
    padding-inline: 8px;
    font-size: .66rem;
  }

  body.auth-page .auth-layout {
    gap: 42px;
  }
}

@media (max-width: 900px) {
  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .topbar__actions {
    grid-column: 2;
    grid-row: 1;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  body.auth-page .auth-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 48px 0 54px;
  }

  body.auth-page .auth-intro {
    max-width: 680px;
  }

  body.auth-page .auth-card {
    max-width: 560px;
  }
}

/* Custom headers hide their nav earlier than the generic header. Keep them
 * reachable with the same toggle on tablet widths. */
@media (max-width: 1280px) {
  body[data-react-page]:not([data-react-page="index"]) .xa-topbar.has-mobile-toggle {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 9px;
  }

  body[data-react-page]:not([data-react-page="index"]) .xa-topbar.has-mobile-toggle > .xa-brand {
    grid-column: 1;
    grid-row: 1;
  }

  body[data-react-page]:not([data-react-page="index"]) .xa-topbar.has-mobile-toggle > .mobile-nav-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
  }

  body[data-react-page]:not([data-react-page="index"]) .xa-topbar.has-mobile-toggle > .auth-slot {
    grid-column: 3;
    grid-row: 1;
    margin-inline-start: 0;
  }

  body[data-react-page]:not([data-react-page="index"]) .xa-topbar.has-mobile-toggle > .xa-refresh {
    grid-column: 4;
    grid-row: 1;
  }

  body[data-react-page]:not([data-react-page="index"]) .xa-topbar.has-mobile-toggle > .xa-nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 2;
  }

  body[data-react-page]:not([data-react-page="index"]) .xa-topbar.has-mobile-toggle.is-mobile-menu-open > .xa-nav {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    z-index: 90;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 3px;
    padding: 9px;
    border: 1px solid rgba(85, 214, 239, .18);
    border-radius: 14px;
    background: rgba(7, 23, 40, .98);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
  }
}

@media (max-width: 1180px) {
  body[data-react-page]:not([data-react-page="index"]) .pro-topbar.has-mobile-toggle {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
  }

  body[data-react-page]:not([data-react-page="index"]) .pro-topbar.has-mobile-toggle > .pro-brand {
    grid-column: 1;
    grid-row: 1;
  }

  body[data-react-page]:not([data-react-page="index"]) .pro-topbar.has-mobile-toggle > .mobile-nav-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
  }

  body[data-react-page]:not([data-react-page="index"]) .pro-topbar.has-mobile-toggle > .pro-nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 3;
  }

  body[data-react-page]:not([data-react-page="index"]) .pro-topbar.has-mobile-toggle > .pro-toolbar {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: flex-end;
  }

  body[data-react-page]:not([data-react-page="index"]) .pro-topbar.has-mobile-toggle.is-mobile-menu-open > .pro-nav {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    z-index: 90;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 3px;
    padding: 9px;
    border: 1px solid rgba(85, 214, 239, .18);
    border-radius: 14px;
    background: rgba(7, 23, 40, .98);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
  }
}

@media (max-width: 760px) {
  body[data-react-page]:not([data-react-page="index"]) .app-shell,
  body[data-react-page]:not([data-react-page="index"]) .site-header__inner,
  body[data-react-page]:not([data-react-page="index"]) .xa-shell,
  body[data-react-page]:not([data-react-page="index"]) .fx-shell,
  body[data-react-page]:not([data-react-page="index"]) .pro-shell,
  .app-shell[data-react-shell="production"] {
    width: min(100% - 24px, 1440px);
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    min-height: 62px;
    padding: 8px 0;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .brand {
    min-width: 0;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .brand strong {
    font-size: .96rem;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .brand small {
    display: none;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .topbar__actions {
    grid-column: 3;
    grid-row: 1;
    width: auto;
    max-width: 100%;
    overflow: visible;
  }

  /* Utility shortcuts are already available from the main menu on mobile. */
  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .topbar__actions .pro-nav-link {
    display: none;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .mobile-nav-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .main-nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 2;
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
    max-height: min(62vh, 430px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 9px;
    border: 1px solid rgba(85, 214, 239, .18);
    border-radius: 14px;
    background: rgba(7, 23, 40, .98);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command).is-mobile-menu-open .main-nav {
    display: flex;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .main-nav a,
  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .main-nav span {
    width: 100%;
    min-height: 38px;
    justify-content: flex-start;
    padding: 9px 11px;
    border-radius: 9px;
    white-space: normal;
  }

  /* Custom page headers use the same toggle behavior as the generic header. */
  body[data-react-page]:not([data-react-page="index"]) .site-header__inner,
  body[data-react-page]:not([data-react-page="index"]) .xa-topbar,
  body[data-react-page]:not([data-react-page="index"]) .fx-topbar,
  body[data-react-page]:not([data-react-page="index"]) .events-topbar,
  body[data-react-page]:not([data-react-page="index"]) .pro-topbar {
    position: relative;
  }

  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .mobile-nav-toggle {
    display: inline-flex;
  }

  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .site-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .xa-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .fx-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .events-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .pro-nav {
    display: none;
  }

  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle.is-mobile-menu-open .site-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle.is-mobile-menu-open .xa-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle.is-mobile-menu-open .fx-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle.is-mobile-menu-open .events-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle.is-mobile-menu-open .pro-nav {
    display: flex;
    position: static;
    width: 100%;
    max-height: min(62vh, 430px);
    overflow-y: auto;
    overflow-x: hidden;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 3px;
    padding: 9px;
    border: 1px solid rgba(85, 214, 239, .18);
    border-radius: 14px;
    background: rgba(7, 23, 40, .98);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
  }

  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .site-nav a,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .xa-nav a,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .xa-nav span,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .fx-nav a,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .fx-nav span,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .events-nav a,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .pro-nav a,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle .pro-nav span {
    width: 100%;
    min-height: 38px;
    padding: 9px 11px;
    border-radius: 9px;
    white-space: normal;
  }

  body[data-react-page]:not([data-react-page="index"]) .site-header__inner.has-mobile-toggle,
  body[data-react-page]:not([data-react-page="index"]) .xa-topbar.has-mobile-toggle,
  body[data-react-page]:not([data-react-page="index"]) .fx-topbar.has-mobile-toggle,
  body[data-react-page]:not([data-react-page="index"]) .events-topbar.has-mobile-toggle,
  body[data-react-page]:not([data-react-page="index"]) .pro-topbar.has-mobile-toggle {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
  }

  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .mobile-nav-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .auth-slot,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .xa-refresh,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .fx-refresh,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .pro-toolbar,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .topbar__actions {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
  }

  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .site-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .xa-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .fx-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .events-nav,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .pro-nav {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .xa-refresh,
  body[data-react-page]:not([data-react-page="index"]) .has-mobile-toggle > .fx-refresh {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: stretch;
    width: 100%;
  }

  body.auth-page .app-shell {
    width: min(100% - 24px, 1220px);
  }

  body.auth-page .auth-layout {
    padding: 34px 0 42px;
    gap: 28px;
  }

  body.auth-page .auth-intro h1 {
    font-size: clamp(2rem, 9vw, 2.8rem);
    line-height: 1.45;
  }

  body.auth-page .auth-intro > p:not(.eyebrow) {
    font-size: .78rem;
    line-height: 2;
  }

  body.auth-page .auth-card {
    padding: 20px;
  }

  body.auth-page .auth-otp__fields {
    grid-template-columns: 1fr;
  }

  body.auth-page .auth-otp__fields .auth-submit {
    width: 100%;
  }
}

@media (max-width: 480px) {
  body[data-react-page]:not([data-react-page="index"]) .mobile-nav-toggle {
    min-height: 35px;
    padding-inline: 9px;
    font-size: .62rem;
  }

  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .topbar__actions .plan-pill,
  body[data-react-page]:not([data-react-page="index"]) .app-shell > .topbar:not(.topbar--command) .topbar__actions .live-pill {
    display: none;
  }

  body.auth-page .auth-trust-list > div {
    padding: 11px 12px;
  }

  body.auth-page .auth-card__heading h2 {
    font-size: 1.15rem;
  }
}

/* React ProductionShell routes (for example /markets) have command menus. */
.app-shell[data-react-shell="production"] .mobile-nav-toggle {
  display: none;
}

@media (max-width: 720px) {
  .app-shell[data-react-shell="production"] {
    width: min(100% - 24px, 1440px);
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 7px;
    min-height: 60px;
    margin-top: 8px;
    padding: 8px;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .mobile-nav-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .command-actions {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .command-nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 2;
    align-items: stretch;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    max-height: min(65vh, 470px);
    overflow-y: auto;
    padding: 9px;
    border: 1px solid rgba(85, 214, 239, .18);
    border-radius: 14px;
    background: rgba(7, 23, 40, .98);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command.is-mobile-menu-open .command-nav {
    display: flex;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .command-nav > a,
  .app-shell[data-react-shell="production"] .topbar.topbar--command .command-nav > .nav-menu > summary {
    width: 100%;
    min-height: 38px;
    justify-content: flex-start;
    padding: 9px 11px;
    border-radius: 9px;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-menu {
    position: static;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-panel {
    position: static;
    display: none;
    width: 100%;
    max-height: none;
    margin-top: 3px;
    padding: 8px;
    transform: none !important;
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-menu[open] > .nav-panel {
    display: grid;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-panel--ban {
    display: none;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-menu--featured[open] > .nav-panel--ban {
    display: block;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-panel--markets,
  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-panel--ban .nav-panel__grid {
    grid-template-columns: 1fr;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-panel__intro {
    margin-bottom: 7px;
  }

  .app-shell[data-react-shell="production"] .topbar.topbar--command .nav-panel--ban .nav-panel__card {
    margin-bottom: 5px;
  }
}
