function ui::logs::wg_row() {
  local ts="${1:-}" client="${2:-}" endpoint="${3:-}" event="${4:-}" \
        count="${5:-1}" w_client="${6:-20}" w_endpoint="${7:-20}" \
        gap_seconds="${8:-}" resolved="${9:-}"
 
  local event_color
  case "$event" in
    handshake) event_color="\033[1;32m" ;;
    attempt)   event_color="\033[1;31m" ;;
    *)         event_color="\033[0;37m" ;;
  esac
 
  local count_suffix=""
  [[ "$count" -gt 1 ]] && count_suffix=" \033[2m(x${count})\033[0m"
 
  # Gap suffix with offline label only when gap > threshold * 2
  local gap_suffix=""
  if [[ "$event" == "handshake" && -n "$gap_seconds" && "$gap_seconds" -gt 0 ]]; then
    local gap_int="$gap_seconds"
    local threshold="${WG_HANDSHAKE_CHECK_TIME_SEC:-300}"
    local offline_threshold=$(( threshold * 2 ))
    local offline_label=""
    [[ "$gap_int" -gt "$offline_threshold" ]] && offline_label=" offline"
    if (( gap_int >= 3600 )); then
      gap_suffix="  \033[2m↑ $(( gap_int / 3600 ))h${offline_label}\033[0m"
    elif (( gap_int >= 60 )); then
      gap_suffix="  \033[2m↑ $(( gap_int / 60 ))m${offline_label}\033[0m"
    fi
  fi
 
  # Build endpoint display: raw_ip [→ resolved dim]
  local endpoint_display="${endpoint:--}"
  if [[ -n "$resolved" && -n "$endpoint" ]]; then
    endpoint_display="${endpoint} \033[2m→ ${resolved}\033[0m"
  fi
  
  if [[ -n "$endpoint" ]]; then
    local resolved
    resolved=$(resolve::ip "$endpoint" 2>/dev/null || echo "")
    if [[ -n "$resolved" && "$resolved" != "$endpoint" ]]; then
      endpoint_display="${endpoint} \033[2m→ ${resolved}\033[0m"
    else
      endpoint_display="$endpoint"
    fi
  else
    endpoint_display="-"
  fi
 
  local client_pad endpoint_pad_n
  client_pad=$(printf "%-${w_client}s" "$client")
  # Use raw endpoint length for padding (resolved part is dim/extra)
  local ep_raw_len=${#endpoint}
  [[ -z "$endpoint" ]] && ep_raw_len=1  # "-"
  endpoint_pad_n=$(( w_endpoint - ep_raw_len ))
  [[ $endpoint_pad_n -lt 0 ]] && endpoint_pad_n=0
 
  local ts_pad
  ts_pad=$(printf "%-11s" "$ts")
 
  printf "  %s  %s  %b%*s  %b%s\033[0m%b%b\n" \
    "$ts_pad" "$client_pad" \
    "$endpoint_display" "$endpoint_pad_n" "" \
    "$event_color" "$event" "$count_suffix" "$gap_suffix"
}