/* Mobile workspace -----------------------------------------------------
   Loaded last so compact layouts are not affected by the legacy desktop
   navigation cascade. */

@media (max-width: 920px) {
  :root {
    --app-header-height: 64px;
  }

  html {
    overflow-x: clip;
    scroll-padding-top: var(--app-header-height);
    overscroll-behavior-x: none;
    background: #030508;
  }

  body {
    min-width: 0;
    overflow-x: clip;
    background: #030508;
  }

  body.nav-hidden .app-header.sidebar {
    transform: none;
  }

  .app-shell {
    padding-top: var(--app-header-height);
  }

  .app-header.sidebar {
    position: fixed;
    z-index: 1200;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    width: 100%;
    height: var(--app-header-height);
    min-height: var(--app-header-height);
    align-items: center;
    flex-direction: row;
    gap: 0.7rem;
    padding: 0.55rem 0.8rem;
    overflow: visible;
    border-bottom: 1px solid #243245;
    background: #05090e;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    transform: none;
    will-change: auto;
  }

  .app-header .brand {
    min-width: 0;
    min-height: 42px;
    align-self: center;
    margin: 0;
    padding: 0;
  }

  .app-header .brand strong {
    font-size: 0.9rem;
    letter-spacing: 0.16em;
  }

  .app-header .brand-mark {
    width: 40px;
    height: 40px;
  }

  .mobile-nav-toggle {
    display: inline-grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    margin-left: auto;
    border: 1px solid #354860;
    border-radius: 8px;
    background: #0a111b;
    color: #f1f6fb;
  }

  .mobile-nav-toggle:focus-visible,
  .mobile-nav-toggle[aria-expanded="true"] {
    border-color: #8bbcff;
    background: #101b2a;
    outline: 2px solid rgba(139, 188, 255, 0.25);
    outline-offset: 2px;
  }

  body.mobile-nav-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .app-header .app-nav,
  .app-header .app-nav.can-scroll-left,
  .app-header .app-nav.can-scroll-right {
    position: fixed;
    z-index: 1190;
    top: var(--app-header-height);
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    width: 100%;
    height: calc(100vh - var(--app-header-height));
    height: calc(100dvh - var(--app-header-height));
    max-width: none;
    max-height: none;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
    padding: 0.9rem 0.8rem max(1.2rem, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    background: #060a10;
    box-shadow: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: none;
    mask-image: none;
    overscroll-behavior: contain;
  }

  .app-header.mobile-nav-open .app-nav {
    display: flex;
  }

  .app-header .nav-group,
  .app-header .nav-group-secondary {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .app-header .nav-group-label {
    display: block;
    padding: 0.35rem 0.8rem 0.2rem;
    color: #7f91a8;
    font-size: 0.68rem;
    letter-spacing: 0.16em;
  }

  .app-header .app-nav .nav-item,
  .app-header .app-nav .nav-group .nav-item {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 48px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.85rem;
    border: 1px solid #1d2a39;
    border-radius: 7px;
    background: #0a1018;
    color: #b7c3d1;
    font-size: 0.86rem;
    text-align: left;
  }

  .app-header .app-nav .nav-item:hover,
  .app-header .app-nav .nav-item:focus-visible,
  .app-header .app-nav .nav-item.active,
  .app-header .app-nav .nav-dropdown-toggle[aria-expanded="true"] {
    border-color: #3a5776;
    background: #0d1723;
    color: #f4f8fc;
    outline: none;
  }

  .app-header .app-nav .nav-item::after {
    top: 11px;
    right: auto;
    bottom: 11px;
    left: 0;
    width: 2px;
    height: auto;
    background: #8bbcff;
    opacity: 0;
    box-shadow: 0 0 12px rgba(139, 188, 255, 0.6);
    transform: none;
  }

  .app-header .app-nav .nav-item.active::after,
  .app-header .app-nav .nav-item[aria-expanded="true"]::after {
    width: 2px;
    opacity: 1;
  }

  .app-header .nav-dropdown {
    display: flex;
    width: 100%;
    flex: 0 0 auto;
    flex-direction: column;
  }

  .app-header .nav-dropdown-menu {
    position: static;
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
    margin: 0.35rem 0 0;
    padding: 0;
    overflow: visible;
    border: 1px solid #223248;
    border-radius: 7px;
    background: #08111d;
    box-shadow: none;
    backdrop-filter: none;
  }

  .app-header .nav-dropdown-menu.hidden {
    display: none;
  }

  .app-header .nav-dropdown-option {
    min-height: 72px;
    grid-template-columns: 28px minmax(0, 1fr) 20px;
    gap: 0.7rem;
    padding: 0.8rem;
    border: 0;
    background: transparent;
  }

  .app-header .nav-dropdown-option + .nav-dropdown-option {
    border-top: 1px solid #223248;
    border-left: 0;
  }

  .app-header .radar-option-copy {
    gap: 0.2rem;
  }

  .app-header .radar-option-copy strong {
    font-size: 1rem;
  }

  .app-header .radar-option-copy small {
    color: #91a0b2;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .app-header .radar-option-arrow {
    opacity: 1;
    transform: none;
  }

  .app-header .account-menu,
  .app-header .app-nav > .account-menu {
    display: flex;
    width: 100%;
    flex: 0 0 auto;
    align-self: stretch;
    justify-content: stretch;
    margin: 0;
  }

  .app-header .account-menu-toggle.nav-item {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0.85rem;
  }

  .app-header .account-menu-toggle .sr-only {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    clip-path: none;
    white-space: normal !important;
  }

  .app-header .account-menu-toggle svg {
    width: 21px;
    height: 21px;
  }

  .app-header .account-menu-panel {
    position: fixed;
    top: calc(var(--app-header-height) + 0.75rem);
    right: 0.75rem;
    bottom: auto;
    left: 0.75rem;
    width: auto;
    max-height: calc(100dvh - var(--app-header-height) - 1.5rem);
    overflow-y: auto;
    border-color: #354b65;
    background: #091019;
  }

  .topbar {
    min-height: 54px;
    margin: 0 -1rem 1rem;
    padding: 0.45rem 1rem;
    border-bottom-color: #26364a;
    background: #05090e;
  }

  .topbar > div:first-child .eyebrow,
  .topbar .sync-status {
    display: none;
  }

  .topbar h1 {
    font-size: 0.92rem;
    letter-spacing: 0.08em;
  }

  .topbar-actions {
    min-width: 0;
    gap: 0.45rem;
  }

  .topbar .language-control {
    min-width: 64px;
  }

  .app-main,
  .app-main > main,
  .page,
  .panel {
    min-width: 0;
  }

  .table-wrap,
  .quick-filters {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }
}

@media (max-width: 700px) {
  .app-main {
    padding-inline: 0.75rem;
  }

  .topbar {
    margin-inline: -0.75rem;
    padding-inline: 0.75rem;
  }

  .radar-command-bar {
    gap: 1.35rem;
    padding-block: 1.7rem 1.3rem;
  }

  #page-radar .command-intro h2,
  #page-small-caps .command-intro h2 {
    font-size: clamp(1.45rem, 7vw, 1.8rem);
    line-height: 1.06;
  }

  .radar-control-deck .toolbar-left {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.55rem;
  }

  .radar-control-deck .toolbar-left input[type="search"] {
    width: 100%;
    min-width: 0;
  }

  .radar-control-deck .toolbar-left .btn {
    min-width: 88px;
    padding-inline: 0.7rem;
  }

  .radar-control-deck .toolbar-right {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .radar-control-deck .quick-filters {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    overflow: visible;
  }

  .radar-control-deck .quick-filter {
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding-inline: 0.55rem;
    white-space: normal;
    text-align: center;
  }

  .radar-panel .table-scroll-shell,
  .watchlist-feed-panel .table-scroll-shell,
  .radar-panel .table-wrap,
  .watchlist-feed-table-wrap {
    min-height: 0;
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  #radar-table,
  #radar-table-smallcap,
  #watchlist-feed-table,
  #radar-table tbody,
  #radar-table-smallcap tbody,
  #watchlist-feed-table tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #radar-table thead,
  #radar-table-smallcap thead,
  #watchlist-feed-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #radar-table tbody,
  #radar-table-smallcap tbody,
  #watchlist-feed-table tbody {
    display: grid;
    gap: 0.75rem;
  }

  #radar-table tbody tr.radar-row,
  #radar-table-smallcap tbody tr.radar-row,
  #watchlist-feed-table tbody tr.radar-row {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid #26384d;
    border-radius: 8px;
    background: #080e16;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  }

  #radar-table tbody tr.radar-row > td,
  #radar-table-smallcap tbody tr.radar-row > td,
  #watchlist-feed-table tbody tr.radar-row > td {
    display: block;
    width: auto;
    min-width: 0;
    max-width: none;
    min-height: 0;
    padding: 0.7rem;
    overflow: hidden;
    border: 0;
    border-top: 1px solid #1b2a3b;
    text-align: left;
  }

  #radar-table tbody tr.radar-row > td::before,
  #radar-table-smallcap tbody tr.radar-row > td::before,
  #watchlist-feed-table tbody tr.radar-row > td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.35rem;
    color: #7f91a7;
    font: 700 0.64rem/1.2 var(--mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  #radar-table tbody tr.radar-row > td:nth-child(2),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(2),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(2) {
    grid-area: 1 / 1 / auto / 4;
    border-top: 0;
    background: #0b1420;
  }

  #radar-table tbody tr.radar-row > td:nth-child(1),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(1),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(1) {
    grid-area: 2 / 1 / auto / 3;
  }

  #radar-table tbody tr.radar-row > td:nth-child(6),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(6),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(6) {
    grid-area: 2 / 3;
  }

  #radar-table tbody tr.radar-row > td:nth-child(3),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(3),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(3) {
    grid-area: 3 / 1;
  }

  #radar-table tbody tr.radar-row > td:nth-child(4),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(4),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(4) {
    grid-area: 3 / 2;
  }

  #radar-table tbody tr.radar-row > td:nth-child(5),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(5),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(5) {
    grid-area: 3 / 3;
  }

  #radar-table .radar-open-button,
  #radar-table-smallcap .radar-open-button,
  #watchlist-feed-table .radar-open-button {
    width: 100%;
    min-height: 62px;
    justify-content: flex-start;
    text-align: left;
  }

  #radar-table .score-meter,
  #radar-table-smallcap .score-meter,
  #watchlist-feed-table .score-meter {
    min-width: 0;
  }

  #radar-table tbody tr.empty-row,
  #radar-table-smallcap tbody tr.empty-row,
  #watchlist-feed-table tbody tr.empty-row,
  #radar-table tbody tr.empty-row td,
  #radar-table-smallcap tbody tr.empty-row td,
  #watchlist-feed-table tbody tr.empty-row td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #news-modal,
  #news-modal-smallcap {
    z-index: 1500;
    overflow-x: hidden;
    overflow-y: auto;
    background: #030608;
    overscroll-behavior: contain;
  }

  #news-modal .news-modal-workspace,
  #news-modal-smallcap .news-modal-workspace {
    display: grid;
    width: 100%;
    height: auto;
    min-height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(360px, 55dvh);
    overflow: visible;
  }

  #news-modal .news-panel,
  #news-modal-smallcap .news-panel {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    border-top: 0;
    border-bottom: 1px solid #30445c;
    border-left: 0;
    box-shadow: none;
  }

  #news-modal .news-chart-panel,
  #news-modal-smallcap .news-chart-panel {
    grid-column: 1;
    grid-row: 2;
    min-height: 360px;
  }

  #news-modal .news-summary,
  #news-modal-smallcap .news-summary {
    padding: 1.35rem 1rem 1.25rem;
  }

  #news-modal .news-summary-header,
  #news-modal-smallcap .news-summary-header {
    align-items: flex-start;
    gap: 0.85rem;
  }

  #news-modal .news-summary-header h3,
  #news-modal-smallcap .news-summary-header h3 {
    font-size: 1.35rem;
    line-height: 1.12;
  }

  #news-modal .news-modal-close,
  #news-modal-smallcap .news-modal-close {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  #news-modal .news-summary-body,
  #news-modal-smallcap .news-summary-body {
    font-size: 0.96rem;
    line-height: 1.6;
  }

  #news-modal .news-list-header,
  #news-modal-smallcap .news-list-header,
  #news-modal .news-timeline,
  #news-modal-smallcap .news-timeline {
    padding-inline: 1rem;
  }

  .news-chart-header {
    min-height: 58px;
    padding-inline: 1rem;
  }

  .news-chart-header > span {
    font-size: 0.66rem;
  }
}

@media (max-width: 480px) {
  .topbar .scanner-health {
    width: 14px;
    min-width: 14px;
    max-width: 14px;
    padding: 0;
    border: 0;
  }

  .topbar .scanner-health .pill {
    display: none;
  }

  .marketing-hero h2 {
    font-size: clamp(2.05rem, 10vw, 2.45rem);
    line-height: 0.95;
  }

  .radar-control-deck .toolbar-left .btn {
    min-width: 78px;
    font-size: 0.74rem;
  }

  #radar-table tbody tr.radar-row,
  #radar-table-smallcap tbody tr.radar-row,
  #watchlist-feed-table tbody tr.radar-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #radar-table tbody tr.radar-row > td:nth-child(2),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(2),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(2) {
    grid-area: 1 / 1 / auto / 3;
  }

  #radar-table tbody tr.radar-row > td:nth-child(1),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(1),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(1) {
    grid-area: 2 / 1;
  }

  #radar-table tbody tr.radar-row > td:nth-child(6),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(6),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(6) {
    grid-area: 2 / 2;
  }

  #radar-table tbody tr.radar-row > td:nth-child(3),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(3),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(3),
  #radar-table tbody tr.radar-row > td:nth-child(4),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(4),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(4),
  #radar-table tbody tr.radar-row > td:nth-child(5),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(5),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(5) {
    grid-area: auto;
  }

  #radar-table tbody tr.radar-row > td:nth-child(5),
  #radar-table-smallcap tbody tr.radar-row > td:nth-child(5),
  #watchlist-feed-table tbody tr.radar-row > td:nth-child(5) {
    grid-column: 1 / 3;
  }
}
