@layer stone-city {
  @media screen and (max-width:760px), screen and (max-width:960px) and (max-height:540px) {
    /* A desktop flex-basis reserves 22rem of height after the header stacks. */
    html #hub-main.hub-flow-main > .page-heading.hub-flow-header {
      display: grid !important;
      grid-template-columns: minmax(0, 1fr);
      height: auto;
      align-items: start !important;
      justify-content: stretch;
      gap: 10px !important;
    }
    html #hub-main .hub-flow-header > div {
      flex: none !important;
      min-block-size: 0;
      align-self: start;
      max-width: 100%;
    }
    html #hub-main .hub-flow-header > .hub-flow-actions { width: 100%; }
    html #hub-main .hub-flow-header > .hub-flow-actions:empty { display: none !important; }
    html .app-shell .hub-nav-utility {
      display: grid !important;
      grid-template-columns: minmax(0, 1fr) fit-content(74%);
      align-items: center;
      gap: 2px 8px;
    }
    html .app-shell .hub-nav-utility .hub-nav-list { min-width: 0; justify-content: flex-end; }
    html .app-shell .hub-nav-utility .hub-phone-profile { min-width: 0; }
  }
}

@layer stone-city {
  @media screen and (max-width:760px), screen and (max-width:960px) and (max-height:540px) {
    html #hub-main .hub-session-compact {
      padding: 6px 10px !important;
      min-block-size: 0;
      gap: 6px;
      font-size: .8rem;
      line-height: 1.4;
    }
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) > .hub-flow-header {
      grid-template-columns: minmax(0, 1fr) fit-content(43%);
      grid-template-areas: "title actions" "subtitle subtitle";
      align-items: center !important;
      gap: 6px 8px !important;
    }
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) .hub-flow-header > div:first-child {
      display: contents;
    }
    /* The full applied dates remain in the global period picker above. */
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) .hub-flow-header .eyebrow {
      display: none !important;
    }
    html #hub-main .hub-flow-header:has(> div:first-child + .hub-flow-actions) h1 { min-inline-size: 0; }
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) .hub-flow-header h1 {
      grid-area: title;
      font-size: clamp(1.5rem, 6vw, 2rem) !important;
    }
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) .hub-flow-header p {
      grid-area: subtitle;
      margin-block: 0 !important;
    }
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) .hub-flow-actions {
      grid-area: actions;
      width: auto !important;
      align-self: center;
      justify-self: end;
      margin: 0 !important;
    }
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) {
      gap: 14px !important;
    }
  }
}

@layer stone-city {
  @media screen and (orientation:landscape) and (min-width:620px) and (max-width:960px) and (max-height:540px) {
    html .app-shell .main-shell .topbar {
      padding-block: max(4px,env(safe-area-inset-top,0px)) 4px !important;
    }
    html .app-shell .topbar .hub-global-picker:not(:has(.hub-edit-range)) {
      grid-template-columns: minmax(0,1fr);
      grid-template-areas: "select" "dates";
      gap: 2px !important;
    }
    html .app-shell .topbar .hub-global-picker .hub-global-dates { line-height: 1.2 !important; }
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) {
      row-gap: 8px !important;
      padding-block-start: 8px !important;
    }
    /* The optional account notice shares a row with the heading on short screens. */
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]):has(> .hub-session-compact) {
      display: grid !important;
      grid-template-columns: minmax(0,1fr) minmax(9rem,25%);
      column-gap: 12px;
      align-items: start;
    }
    html #hub-main:has(> .hub-session-compact):is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) > * { grid-column: 1/-1; }
    html #hub-main:has(> .hub-session-compact):is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) > .hub-flow-header { grid-area: 1/1/2/2; }
    html #hub-main:is([data-hub-route-content="leaderboard"],[data-hub-route-content="averages"]) > .hub-session-compact { grid-area: 1/2/2/3; align-self: center; }
    html #hub-main .hub-trending-production .hub-production-heading-copy {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      column-gap: 18px;
    }
    html #hub-main .hub-trending-production .hub-production-meta { margin: 0 !important; }
  }
}

@layer stone-city {
  html #hub-main .hub-standings-first .hub-board-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    column-gap: 8px;
    row-gap: 4px;
    min-width: 0;
  }
  html #hub-main .hub-board-caption { min-width: 0; }
  html #hub-main .hub-board-caption h2 { margin: 0 !important; font-size: 1.16rem !important; line-height: 1.2; }
  html #hub-main .hub-board-caption p { margin: 2px 0 0 !important; font-size: .8rem !important; line-height: 1.3; overflow-wrap: anywhere; }
  html #hub-main .hub-board-actions { display: flex; align-items: center; gap: 4px; }
  html #hub-main .hub-board-actions .text-button {
    min-height: 44px; min-width: 44px; padding-inline: 8px !important; font-size: .82rem !important;
    color: var(--sc-gold-light,LinkText) !important; text-decoration: underline; text-underline-offset: 3px;
  }
  html #hub-main .hub-board-search { margin-block: 6px; }
  html #hub-main .hub-board-search .search-control { display: inline-flex; box-sizing: border-box; width: min(100%,24rem) !important; min-width: 0; min-height: 44px; }
  html #hub-main .hub-board-search input { width: 100%; min-width: 0; }
  html #hub-main .hub-standings-first [hidden] { display: none !important; }
  html #hub-main .hub-board-message { min-width: 0; padding-block: 12px; overflow-wrap: anywhere; }
  html #hub-main .hub-board-message :is(h2,h3,p) { margin: 0 0 4px; }
  html #hub-main .hub-board-message :is(.btn,.text-button) { min-height: 44px; }
  html #hub-main .hub-board-footer { display: flex; flex-wrap: wrap; gap: 8px 24px; }
  html #hub-main .hub-board-podium { min-width: 0; }
}
@layer stone-city {
@media screen and (max-width:760px), screen and (max-width:960px) and (max-height:540px) and (orientation:landscape) {
  html #hub-main:has(> .hub-standings-first) { row-gap: 12px !important; }
  html #hub-main .hub-standings-first .hub-board-toolbar { gap: 0 5px !important; }
  html #hub-main .hub-standings-first .hub-board-actions .text-button { padding-inline: 5px !important; }
  html #hub-main .hub-board-search .search-control input { font-size: 16px !important; }
  /* One native row with the rank, identity and exact formatted amount together.
     Daily counts, status and the existing profile button are still present. */
  html #hub-main .hub-standings-first .hub-phone-standings tbody > tr[data-hub-rank-agent] {
    grid-template-columns: 25px minmax(0,1.15fr) minmax(0,1fr) 44px !important;
    align-items: center !important; column-gap: 4px !important; padding-block: 6px 12px !important;
  }
  html #hub-main .hub-standings-first .hub-phone-standings tbody > tr[data-hub-rank-agent] > td:nth-child(1) { grid-column: 1 !important; grid-row: 1 !important; }
  html #hub-main .hub-standings-first .hub-phone-standings tbody > tr[data-hub-rank-agent] > td:nth-child(2) { grid-column: 2 !important; grid-row: 1 !important; }
  html #hub-main .hub-standings-first .hub-phone-standings tbody > tr[data-hub-rank-agent] > td.alp-cell {
    grid-row: 1 !important; grid-column: 3 !important;
    padding: 0 !important; align-self: center; font-weight: 650; text-align: end !important;
  }
  html #hub-main .hub-standings-first .hub-phone-standings tbody > tr[data-hub-rank-agent] > td:last-child { grid-column: 4 !important; grid-row: 1 !important; }
  html #hub-main .hub-standings-first .hub-phone-standings .agent-link { padding: 0 !important; }
  html #hub-main .hub-standings-first .hub-phone-standings .agent-link .avatar { display: none !important; }
}
}
@layer stone-city {
  @media screen and (orientation:landscape) and (min-width:620px) and (max-width:960px) and (max-height:540px) {
    html #hub-main .hub-standings-first .hub-phone-standings tbody > tr[data-hub-rank-agent] > td.alp-cell {
      display: flex !important;
      flex-direction: row !important;
      align-items: center !important;
      justify-content: flex-end;
      gap: 6px;
    }
  }
}

@layer stone-city {
@media screen {
  html #hub-main .hub-trending-production {
    display:block;box-sizing:border-box;width:100%;max-width:100%;min-width:0;
  }
  html #hub-main .hub-trending-production .hub-production-heading-copy {min-width:0}
  html #hub-main .hub-trending-production h2 {white-space:normal!important;overflow-wrap:anywhere}
  html #hub-main .hub-trending-production .hub-production-chart {min-width:0;max-width:100%}
  html #hub-main .hub-trending-production .hub-chart-scroll {width:100%;box-sizing:border-box}
  html #hub-main .hub-trending-production :is(.hub-trending-partial,.hub-trending-empty) {
    margin:12px 0 0;padding:9px 0 0;border-top:1px solid var(--sc-line,#806c71);
    font-size:14px;line-height:1.5;color:var(--sc-sub,#e1d9cc)!important;white-space:normal;
  }
}
}

@layer stone-city {
  @media screen and (max-width:760px), screen and (max-width:960px) and (max-height:540px) {
    html #hub-main .hub-trending-production .hub-production-chart {
      display: flex !important;
      flex-direction: column;
      gap: 8px !important;
      margin-block-start: 6px !important;
    }
    html #hub-main .hub-trending-production .hub-chart-scroll { order: 0; }
    html #hub-main .hub-trending-production .hub-phone-scroll-tools { order: 1; }
    html #hub-main .hub-trending-production .hub-chart-readout { order: 2; }
    html #hub-main .hub-trending-production .hub-chart-footer { order: 3; }
    html #hub-main .hub-trending-production .hub-production-heading { margin-block-end: 0 !important; }
    html #hub-main .hub-trending-production .hub-chart-track { height: clamp(80px, 15vh, 126px) !important; }
  }
}
