/* Mobile app frame: the navigation has its own grid row, never an overlay.
   No fixed/sticky bottom positioning or visualViewport offsets are needed. */
@media (max-width: 820px) {
  html:has(#app > .shell) {
    overflow: hidden;
    scroll-padding: 0;
  }

  body:has(#app > .shell) {
    overflow: hidden;
    min-height: 0;
    padding-bottom: 0;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  #app:has(> .shell) { min-height: 0; }

  #app > .shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: #f6f7fb;
  }

  #app > .shell > .main {
    grid-area: 1 / 1;
    display: block;
    min-height: 0;
    overflow: auto;
    overscroll-behavior-y: contain;
    scroll-padding-block: calc(72px + env(safe-area-inset-top)) 20px;
    -webkit-overflow-scrolling: touch;
  }

  #app > .shell > .sidebar {
    grid-area: 2 / 1;
    position: static;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 5px max(8px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    overflow: visible;
    border-top: 1px solid #e1e3ee;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .shell > .sidebar .nav {
    align-items: stretch;
    gap: 3px;
    padding: 0;
  }

  .shell > .sidebar .nav-button {
    position: relative;
    height: auto;
    min-height: 56px;
    grid-template-rows: 22px auto;
    align-content: center;
    gap: 4px;
    padding: 6px 2px;
    border-radius: 10px;
    font-size: .75rem;
    line-height: 1.3;
    white-space: normal;
    box-shadow: none;
    color: #65677d;
  }

  .shell > .sidebar .nav-button.active {
    color: #5040c9;
    background: #efecff;
    box-shadow: inset 0 2px #6555f5;
  }

  .shell > .sidebar .nav-button .badge {
    position: absolute;
    top: 2px;
    right: 4px;
    display: inline-flex;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: #b72e4b;
    color: #fff;
    font-size: .75rem;
    line-height: 1;
  }

  .shell > .main > .topbar {
    position: sticky;
    top: 0;
    min-height: 60px;
    padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    border-bottom: 1px solid #e8e9f0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .shell .topbar > div:first-child { flex: 1 1 auto; min-width: 0; }
  .shell .topbar h1 { max-width: none; white-space: normal; font-size: 1.125rem; line-height: 1.4; }
  .shell .topbar-context { display: none; }
  .shell .mobile-user-status { flex: 0 0 auto; gap: 8px; }
  .shell .mobile-user-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: auto;
    min-width: 44px;
    min-height: 44px;
    height: auto;
    padding: 8px;
    border: 1px solid #e1e3ee;
    border-radius: 10px;
    background: #fff;
    color: #393451;
    font-size: .875rem;
    font-weight: 700;
    box-shadow: none;
  }
  .mobile-user-menu-button svg { width: 18px; height: 18px; }
  .shell .mobile-user-status .status-pill { font-size: .75rem; }

  .shell > .main > .content {
    padding: 12px max(12px, env(safe-area-inset-right)) 24px max(12px, env(safe-area-inset-left));
  }
  .shell .content-stack { gap: 14px; }
  .shell .panel, .shell .admin-command-center {
    padding: 16px;
    border: 1px solid #e5e6f0;
    border-radius: 14px;
    background: #fff;
    box-shadow: none;
  }
  .shell .panel-header { gap: 10px; margin-bottom: 14px; }
  .shell .panel-title, .shell .panel h2, .shell .admin-command-copy h2 {
    font-size: 1.125rem;
    line-height: 1.5;
    letter-spacing: normal;
  }
  .shell .panel-subtitle, .shell .admin-command-copy > p:not(.section-eyebrow) {
    margin-top: 4px;
    font-size: .875rem;
    line-height: 1.6;
    color: #68677b;
  }
  .shell .btn { min-height: 44px; border-radius: 10px; font-size: .875rem; line-height: 1.5; box-shadow: none; }
  .shell input:not([type="checkbox"]):not([type="radio"]), .shell select, .shell textarea {
    max-width: 100%;
    min-width: 0;
    font-size: 1rem;
    scroll-margin-block: 80px 24px;
  }
  .shell .field label, .shell .field-help { font-size: .875rem; line-height: 1.6; }
  .shell .request-tabs button, .shell .review-tabs button { font-size: .875rem; line-height: 1.5; }

  .admin-dashboard .admin-command-center { gap: 14px; }
  .admin-dashboard .admin-command-copy h2 { margin: 10px 0 0; }
  .admin-dashboard .review-month { justify-content: space-between; gap: 8px; }
  .admin-dashboard .review-month input { flex: 1 1 auto; min-height: 44px; max-width: 12rem; }
  .admin-dashboard .admin-command-cards { gap: 8px; }
  .admin-dashboard .admin-command-card {
    min-height: 0;
    grid-template-columns: 28px minmax(0, 1fr) 12px;
    gap: 10px;
    padding: 12px;
    border-radius: 10px;
    background: #fff;
    box-shadow: none;
    transform: none;
  }
  .admin-dashboard .admin-command-card.attention { border-color: #e8d4dc; background: #fffafb; }
  .admin-dashboard .admin-command-number { width: 28px; height: 28px; border-radius: 8px; font-size: .875rem; }
  .admin-dashboard .admin-command-card > span:nth-child(2) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 3px 10px;
  }
  .admin-dashboard .admin-command-card small { font-size: .875rem; line-height: 1.5; }
  .admin-dashboard .admin-command-card strong { margin: 0; font-size: 1.125rem; line-height: 1.5; }
  .admin-dashboard .admin-command-card em { flex-basis: 100%; margin: 0; font-size: .8125rem; line-height: 1.5; }
  .admin-dashboard .admin-command-actions { gap: 8px; }
  .admin-dashboard .admin-command-actions .btn { min-height: 44px; padding: 10px 12px; }
  .admin-dashboard .admin-command-actions .btn.ghost { background: #fff; border-color: #e1e3ee; }
  .admin-dashboard .admin-status-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .admin-dashboard .admin-status-strip .kpi { padding: 12px; border-radius: 10px; background: #f7f8fc; box-shadow: none; }
  .admin-dashboard .admin-status-strip .kpi strong { font-size: 1.25rem; line-height: 1.35; }
  .admin-dashboard .admin-status-strip .kpi span { font-size: .875rem; line-height: 1.5; }
  .admin-team-now .panel-header { flex-direction: row; align-items: center; }
  .admin-team-now .panel-header .btn { width: auto; flex: 0 0 auto; padding-inline: 10px; }

  .mobile-account-sheet { max-height: calc(100dvh - env(safe-area-inset-top) - 12px); overflow-y: auto; }
  .mobile-account-links { flex: 1 1 auto; min-height: 0; }
  .mobile-account-head { grid-template-columns: 40px minmax(0, 1fr) 44px; }
  .mobile-account-head .modal-close { width: 44px; height: 44px; }
  .mobile-menu-group a { min-height: 52px; }
  .mobile-menu-group a strong { font-size: 1rem; }
  .mobile-menu-group a small { font-size: .8125rem; line-height: 1.5; }
  .shell:has(~ .mobile-account-backdrop) > .main { overflow: hidden; }
}

@media (max-width: 380px) {
  .shell .mobile-user-status > .status-pill { display: none; }
  .admin-team-now .panel-header { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .shell .nav-button, .shell .admin-command-card { transition: none; }
}
