/* Mobile navigation and the compact app header. Desktop keeps its full sidebar. */
.mobile-nav-icon,
.mobile-more-tab,
.mobile-admin-bottom-nav,
.mobile-admin-section-tabs {
  display: none !important;
}

/* Tablets retain the full navigation while allowing all header actions to wrap. */
@media (min-width: 761px) and (max-width: 860px) {
  .app-shell .topbar {
    align-items: stretch !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    max-width: 100%;
    min-width: 0;
    overflow: visible !important;
  }

  .app-shell .topbar > div,
  .app-shell .topbar .title-row {
    max-width: 100%;
    min-width: 0;
  }

  .app-shell .topbar .title-row {
    flex-wrap: wrap;
  }

  .app-shell .top-actions {
    align-items: center !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: flex-start !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .app-shell .top-actions > * {
    flex: 0 1 auto;
    max-width: 100%;
    min-width: 0;
    width: auto !important;
  }

  .app-shell .top-actions > button {
    min-height: 44px;
  }

  .app-shell .top-actions .quote-refresh {
    flex-wrap: wrap;
    max-width: 100%;
  }

  html[data-theme="dark"] .app-shell #view-posicoes .asset-group,
  html[data-theme="dark"] .app-shell #view-posicoes .group-head {
    background: var(--surface) !important;
    border-color: var(--line) !important;
    color: var(--ink);
  }

  html[data-theme="dark"] .app-shell #view-posicoes .group-stat {
    background: var(--surface-2) !important;
    border-color: var(--line) !important;
    color: var(--muted) !important;
  }

  html[data-theme="dark"] .app-shell #view-posicoes .group-stat strong:not(.positive):not(.negative) {
    color: var(--ink) !important;
  }
}

.mobile-more-panel {
  background: #fff;
  border: 1px solid #dce5eb;
  border-radius: 24px 24px 0 0;
  color: #132137;
  inset: auto 0 0;
  margin: 0 auto;
  max-height: calc(100dvh - 24px);
  max-width: 540px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  box-sizing: border-box;
}

.mobile-more-panel::backdrop {
  background: rgba(4, 12, 24, .56);
  backdrop-filter: blur(3px);
}

body:has(#mobileMoreDialog[open]) {
  overflow: hidden;
}

.mobile-more-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.mobile-more-heading p {
  color: #64748b;
  font-size: 12px;
  margin: 0 0 4px;
}

.mobile-more-heading h2 {
  font-size: 24px;
  margin: 0;
}

.mobile-more-panel button {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  font-family: inherit;
  gap: 12px;
  min-height: 48px;
  text-align: left;
}

.mobile-more-panel button:focus-visible,
.mobile-more-tab:focus-visible,
.mobile-primary-tab:focus-visible {
  outline: 3px solid #477b1b;
  outline-offset: 3px;
}

.mobile-more-panel button:disabled {
  cursor: wait;
  opacity: .6;
}

.mobile-more-panel svg,
.mobile-nav-icon svg {
  fill: none;
  flex-shrink: 0;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 22px;
}

#mobileCloseMore {
  border: 1px solid #dce5eb;
  border-radius: 50%;
  justify-content: center;
  padding: 0;
  width: 44px;
  min-height: 44px;
}

.mobile-more-destinations {
  display: grid;
  gap: 4px;
}

.mobile-more-destinations button {
  border-radius: 12px;
  padding: 12px;
  width: 100%;
}

.mobile-more-destinations button:hover,
.mobile-more-destinations button[aria-current="page"] {
  background: #f1f7eb;
}

.mobile-more-destinations button > span:not(.mobile-more-chevron) {
  display: grid;
  flex: 1;
  gap: 4px;
}

.mobile-more-destinations strong {
  font-size: 15px;
  font-weight: 700;
}

.mobile-more-destinations small {
  color: #64748b;
  font-size: 12px;
  line-height: 1.4;
}

.mobile-more-chevron {
  color: #7b8898;
  font-size: 24px;
}

.mobile-more-tools {
  border-top: 1px solid #e3eaf0;
  display: grid;
  margin-top: 12px;
  padding: 12px 0 0;
}

.mobile-more-tools button {
  border-radius: 12px;
  font-size: 14px;
  padding: 10px 12px;
}

.mobile-more-tools button:hover {
  background: #f3f6f9;
}

html[data-theme="dark"] .mobile-more-panel {
  background: #111b2b;
  border-color: #2b394e;
  color: #f5f8fc;
}

html[data-theme="dark"] .mobile-more-heading p,
html[data-theme="dark"] .mobile-more-destinations small {
  color: #a6b5ca;
}

html[data-theme="dark"] #mobileCloseMore,
html[data-theme="dark"] .mobile-more-tools {
  border-color: #2b394e;
}

html[data-theme="dark"] .mobile-more-destinations button:hover,
html[data-theme="dark"] .mobile-more-destinations button[aria-current="page"],
html[data-theme="dark"] .mobile-more-tools button:hover {
  background: #223427;
}

@media (max-width: 760px) {
  .app-shell .admin-desktop-sidebar {
    display: none !important;
  }

  .mobile-admin-bottom-nav {
    background: rgba(8, 14, 26, .97);
    border-top: 1px solid rgba(255, 255, 255, .12);
    border-radius: 18px 18px 0 0;
    bottom: 0;
    box-shadow: 0 -18px 42px rgba(7, 13, 24, .2);
    box-sizing: border-box;
    left: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) !important;
    position: fixed;
    right: 0;
    z-index: 100;
  }

  .mobile-admin-section-tabs {
    display: flex !important;
    gap: 8px;
    margin-bottom: 16px;
  }

  .mobile-admin-section-tabs button {
    border: 1px solid #d1dce6;
    border-radius: 10px;
    background: #fff;
    color: #243348;
    flex: 1;
    font: inherit;
    min-height: 44px;
  }

  .mobile-admin-section-tabs button.active {
    background: #e7f3d9;
    border-color: #a1c875;
  }

  html[data-theme="dark"] .mobile-admin-section-tabs button {
    background: #152238;
    border-color: #304359;
    color: #f5f8fc;
  }

  html[data-theme="dark"] .mobile-admin-section-tabs button.active {
    background: #28402c;
    border-color: #507c39;
  }

  .app-shell .side-nav nav,
  .mobile-admin-bottom-nav {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr 1.35fr .8fr !important;
    gap: 2px !important;
    overflow: visible !important;
    scroll-snap-type: none !important;
  }

  .app-shell .side-nav nav {
    padding: 0 !important;
  }

  .app-shell .side-nav {
    border-radius: 18px 18px 0 0 !important;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) !important;
  }

  .app-shell .side-tab.mobile-secondary-tab {
    display: none !important;
  }

  .app-shell .side-tab.mobile-primary-tab,
  .app-shell .side-tab.mobile-more-tab {
    border-radius: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    font-size: 10px !important;
    gap: 5px !important;
    line-height: 1.2 !important;
    min-height: 54px !important;
    min-width: 0 !important;
    padding: 6px 0 !important;
    white-space: nowrap !important;
  }

  .app-shell .side-tab::after {
    content: none !important;
    display: none !important;
  }

  .app-shell .side-tab-label {
    display: block;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: -.25px;
    line-height: 1.2;
  }

  .app-shell .mobile-nav-icon {
    display: flex !important;
    height: 22px;
    justify-content: center;
  }

  .app-shell .side-tab.active {
    background: rgba(166, 255, 61, .13) !important;
    color: #b8ff6e !important;
  }

  .mobile-app-header {
    gap: 12px;
    min-height: 64px;
    padding: 10px 16px;
    box-sizing: border-box;
  }

  .mobile-app-header > img {
    height: 38px;
    max-width: 132px;
  }

  .mobile-header-actions {
    gap: 10px;
  }

  .mobile-header-actions button {
    height: 44px;
    min-height: 44px;
    min-width: 44px;
    width: 44px;
  }

  .mobile-trial-panel.active-plan {
    border-radius: 12px;
    box-shadow: none;
    gap: 8px;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    margin: 10px 14px 0;
    padding: 4px 10px;
  }

  .mobile-trial-panel.active-plan > span {
    align-self: center;
    font-size: 17px;
    padding: 0;
  }

  .mobile-trial-panel.active-plan p {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
  }

  .mobile-trial-panel.active-plan button {
    background: transparent;
    border-radius: 8px;
    box-shadow: none;
    color: inherit;
    font-size: 12px;
    font-weight: 700;
    grid-column: auto;
    min-height: 44px;
    padding: 0 6px;
    text-decoration: underline;
    text-underline-offset: 3px;
    width: auto;
  }
}
